限制裁剪框放大时超出画布范围

- 双指缩放裁剪框时添加边界检测
- 裁剪框超出边界时停止放大,保持在画布内
This commit is contained in:
2026-04-28 10:45:42 +08:00
parent 990ca8e27c
commit a12577a369
2 changed files with 11 additions and 4 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 28 10:21:42 CST 2026
#Tue Apr 28 10:32:14 CST 2026
stageCount=7
libraryProject=
baseVersion=15.0
publishVersion=15.0.6
buildCount=37
buildCount=39
baseBetaVersion=15.0.7

View File

@@ -414,8 +414,15 @@ public class CropCanvasView extends View {
newWidth = Math.max(minSize, Math.min(newWidth, canvasBounds.width()));
newHeight = newWidth / coverRatio;
cropRect.set(centerX - newWidth / 2, centerY - newHeight / 2,
centerX + newWidth / 2, centerY + newHeight / 2);
float newLeft = centerX - newWidth / 2;
float newTop = centerY - newHeight / 2;
float newRight = centerX + newWidth / 2;
float newBottom = centerY + newHeight / 2;
if (newLeft >= canvasBounds.left && newRight <= canvasBounds.right &&
newTop >= canvasBounds.top && newBottom <= canvasBounds.bottom) {
cropRect.set(newLeft, newTop, newRight, newBottom);
}
initialSpan = span;
invalidate();