diff options
| author | Selim Cinek <cinek@google.com> | 2014-03-14 18:42:48 +0100 |
|---|---|---|
| committer | Adrian Roos <roosa@google.com> | 2014-03-14 20:11:17 +0000 |
| commit | eb95e74e21a0e910704ca2fd67e074ab640bfba3 (patch) | |
| tree | 0ea6428ec29846bb5ec23cfa0a803d2e066df8d0 | |
| parent | ff89d589c7eb32265bf70068ffaef24104a580a5 (diff) | |
| download | frameworks_base-eb95e74e21a0e910704ca2fd67e074ab640bfba3.zip frameworks_base-eb95e74e21a0e910704ca2fd67e074ab640bfba3.tar.gz frameworks_base-eb95e74e21a0e910704ca2fd67e074ab640bfba3.tar.bz2 | |
DO NOT MERGE - Fixed crash for odd image width/height
Due to an internal rounding in the renderer, the calculations
for the cropping area could be slightly offset, getting out
of the image boundaries. I sanitized the rect by ensuring they
are inside the image.
Bug: 12174629
Change-Id: Icc37790732ddd479631b898b23c05501d2dcd5be
| -rw-r--r-- | packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java index 57c0581..7b3f112 100644 --- a/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java +++ b/packages/WallpaperCropper/src/com/android/wallpapercropper/WallpaperCropActivity.java @@ -340,6 +340,13 @@ public class WallpaperCropActivity extends Activity { getWindowManager()); // Get the crop RectF cropRect = mCropView.getCrop(); + + // Due to rounding errors in the cropview renderer the edges can be slightly offset + // therefore we ensure that the boundaries are sanely defined + cropRect.left = Math.max(0, cropRect.left); + cropRect.right = Math.min(mCropView.getWidth(), cropRect.right); + cropRect.top = Math.max(0, cropRect.top); + cropRect.bottom = Math.min(mCropView.getHeight(), cropRect.bottom); int cropRotation = mCropView.getImageRotation(); float cropScale = mCropView.getWidth() / (float) cropRect.width(); |
