完善剪裁窗口颜色拾取功能,工具栏图标同步更新
This commit is contained in:
@@ -127,6 +127,7 @@ public class CropActivity extends AppCompatActivity {
|
||||
public void onColorPicked(int color) {
|
||||
int pickX = cropCanvasView.getLastPickImageX();
|
||||
int pickY = cropCanvasView.getLastPickImageY();
|
||||
colorView.setBackgroundColor(color);
|
||||
Toast.makeText(CropActivity.this,
|
||||
"颜色已拾取: #" + String.format("%06X", color & 0xFFFFFF) +
|
||||
" (" + pickX + "," + pickY + ")",
|
||||
|
||||
@@ -528,10 +528,19 @@ public class CropCanvasView extends View {
|
||||
return true;
|
||||
}
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (previewColor != 0 && previewColor != Color.TRANSPARENT) {
|
||||
backgroundColor = previewColor;
|
||||
if (canvasBounds.contains(x, y)) {
|
||||
int pickedColor;
|
||||
float imgX = screenToImageX(x);
|
||||
float imgY = screenToImageY(y);
|
||||
if (imageBounds.contains(imgX, imgY)) {
|
||||
int colorAtPoint = getImageColorAt(x, y);
|
||||
pickedColor = colorAtPoint;
|
||||
backgroundColor = colorAtPoint;
|
||||
} else {
|
||||
pickedColor = backgroundColor;
|
||||
}
|
||||
if (colorPickedListener != null) {
|
||||
colorPickedListener.onColorPicked(backgroundColor);
|
||||
colorPickedListener.onColorPicked(pickedColor);
|
||||
}
|
||||
}
|
||||
if (colorPickEndListener != null) {
|
||||
|
||||
Reference in New Issue
Block a user