限制裁剪框放大时超出画布范围
- 双指缩放裁剪框时添加边界检测 - 裁剪框超出边界时停止放大,保持在画布内
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user