From fb2b30bf479dc85cd9b50d4b4fe7cd3c6a60c5e6 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Sun, 6 Sep 2015 12:38:32 +0200 Subject: trebuchet: ensure crop bounds Ensure that crop rect is not bigger than original bitmap size Change-Id: Ifb2b261411a75c9792d34b925e3ff3d3c2bde59d JIRA: BUGDUMP-3529433 Signed-off-by: Jorge Ruesga --- .../src/com/android/launcher3/WallpaperCropActivity.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java index d5c7cd93d..b571e7124 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java @@ -698,10 +698,10 @@ public class WallpaperCropActivity extends Activity { // Adjust the width roundedTrueCrop.right = roundedTrueCrop.left + fullSize.getWidth(); } - if (roundedTrueCrop.right > fullSize.getWidth()) { + if (roundedTrueCrop.right >= fullSize.getWidth()) { // Adjust the left value - int adjustment = roundedTrueCrop.left - - Math.max(0, roundedTrueCrop.right - roundedTrueCrop.width()); + int adjustment = Math.max(0, + roundedTrueCrop.right - fullSize.getWidth()); roundedTrueCrop.left -= adjustment; roundedTrueCrop.right -= adjustment; } @@ -709,10 +709,10 @@ public class WallpaperCropActivity extends Activity { // Adjust the height roundedTrueCrop.bottom = roundedTrueCrop.top + fullSize.getHeight(); } - if (roundedTrueCrop.bottom > fullSize.getHeight()) { + if (roundedTrueCrop.bottom >= fullSize.getHeight()) { // Adjust the top value - int adjustment = roundedTrueCrop.top - - Math.max(0, roundedTrueCrop.bottom - roundedTrueCrop.height()); + int adjustment = Math.max(0, + roundedTrueCrop.bottom - fullSize.getHeight()); roundedTrueCrop.top -= adjustment; roundedTrueCrop.bottom -= adjustment; } -- cgit v1.2.3