<gallery>优化裁剪功能:更新颜色拾取逻辑、同步工具栏图标、调整布局文件

This commit is contained in:
2026-04-28 19:46:23 +08:00
parent dad179c15f
commit c320b7f0bf
5 changed files with 20 additions and 14 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 28 18:27:43 CST 2026
#Tue Apr 28 19:41:44 CST 2026
stageCount=10
libraryProject=
baseVersion=15.0
publishVersion=15.0.9
buildCount=3
buildCount=11
baseBetaVersion=15.0.10

View File

@@ -3,6 +3,7 @@ package cc.winboll.studio.gallery;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.RectF;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.content.DialogInterface;
@@ -115,10 +116,11 @@ public class CropActivity extends AppCompatActivity {
cropCanvasView = findViewById(R.id.crop_canvas_view);
final View colorView = findViewById(R.id.color_view);
final GradientDrawable colorDrawable = (GradientDrawable) colorView.getBackground();
cropCanvasView.setOnBackgroundColorChangedListener(new CropCanvasView.OnBackgroundColorChangedListener() {
@Override
public void onBackgroundColorChanged(int color) {
colorView.setBackgroundColor(color);
colorDrawable.setColor(color);
}
});
@@ -127,7 +129,7 @@ public class CropActivity extends AppCompatActivity {
public void onColorPicked(int color) {
int pickX = cropCanvasView.getLastPickImageX();
int pickY = cropCanvasView.getLastPickImageY();
colorView.setBackgroundColor(color);
colorDrawable.setColor(color);
Toast.makeText(CropActivity.this,
"颜色已拾取: #" + String.format("%06X", color & 0xFFFFFF) +
" (" + pickX + "," + pickY + ")",
@@ -143,7 +145,7 @@ public class CropActivity extends AppCompatActivity {
}
});
colorView.setBackgroundColor(cropCanvasView.getBackgroundColor());
colorDrawable.setColor(cropCanvasView.getBackgroundColor());
loadImage();
}

View File

@@ -518,7 +518,15 @@ public class CropCanvasView extends View {
if (colorPickMode) {
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
if (originalBitmap != null && !originalBitmap.isRecycled()) {
previewColor = getImageColorAt(x, y);
float imgX = screenToImageX(x);
float imgY = screenToImageY(y);
if (imageBounds.contains(imgX, imgY)) {
previewColor = getImageColorAt(x, y);
} else if (canvasBounds.contains(x, y)) {
previewColor = backgroundColor;
} else {
previewColor = Color.TRANSPARENT;
}
lastPickX = x;
lastPickY = y;
if (backgroundColorChangedListener != null) {

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@android:color/holo_green_dark"/>
<solid android:color="@android:color/transparent"/>
<stroke android:width="2dp" android:color="@android:color/white"/>
<size android:width="32dp" android:height="32dp"/>
</shape>

View File

@@ -25,7 +25,8 @@
android:id="@+id/color_icon_container"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="8dp">
android:layout_marginStart="8dp"
android:background="@android:color/transparent">
<View
android:id="@+id/color_view"
@@ -34,12 +35,6 @@
android:layout_gravity="center"
android:background="@drawable/bg_color_circle"/>
<View
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:background="@drawable/bg_color_circle_border"/>
</FrameLayout>
<ImageView