diff options
| author | Ruben Brunk <rubenbrunk@google.com> | 2012-11-28 15:46:05 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-11-28 15:46:05 -0800 |
| commit | 7681f68e37fef0a7cf20de99d99e628ca5653f36 (patch) | |
| tree | d5a0ec78e1c900d8cce1699faa53ca87ca99f328 /src | |
| parent | a5fbd5f8007acd7ae757816d6774731576a05ea6 (diff) | |
| parent | 6a94446de01e8b6b034cc537ee3e65d507d47a47 (diff) | |
| download | android_packages_apps_Gallery2-7681f68e37fef0a7cf20de99d99e628ca5653f36.tar.gz android_packages_apps_Gallery2-7681f68e37fef0a7cf20de99d99e628ca5653f36.tar.bz2 android_packages_apps_Gallery2-7681f68e37fef0a7cf20de99d99e628ca5653f36.zip | |
am 6a94446d: Minor fix for some FP rounding errors in crop.
* commit '6a94446de01e8b6b034cc537ee3e65d507d47a47':
Minor fix for some FP rounding errors in crop.
Diffstat (limited to 'src')
3 files changed, 10 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java index bdcb0ea4e..d74a6faab 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java @@ -72,7 +72,7 @@ public class ImageFilterGeometry extends ImageFilter { Rect cropBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF crop = mGeometry.getCropBounds(bitmap); if (crop.width() > 0 && crop.height() > 0) - crop.roundOut(cropBounds); + cropBounds = GeometryMath.roundNearest(crop); Bitmap temp = null; if (mGeometry.hasSwitchedWidthHeight()) { temp = Bitmap.createBitmap(cropBounds.height(), cropBounds.width(), mConfig); diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java index 33a3f73cb..55f791820 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java @@ -16,6 +16,7 @@ package com.android.gallery3d.filtershow.imageshow; +import android.graphics.Rect; import android.graphics.RectF; public class GeometryMath { @@ -99,4 +100,10 @@ public class GeometryMath { return Math.min(newWidth / oldWidth , newHeight / oldHeight); } + public static Rect roundNearest(RectF r){ + Rect q = new Rect(Math.round(r.left), Math.round(r.top), Math.round(r.right), + Math.round(r.bottom)); + return q; + } + } diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java index cf52b15ca..dffdc2449 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java +++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java @@ -59,10 +59,8 @@ public class GeometryMetadata { if (mStraightenRotation != 0) { return true; } - Rect cropBounds = new Rect(); - mCropBounds.roundOut(cropBounds); - Rect photoBounds = new Rect(); - mPhotoBounds.roundOut(photoBounds); + Rect cropBounds = GeometryMath.roundNearest(mCropBounds); + Rect photoBounds = GeometryMath.roundNearest(mPhotoBounds); if (!cropBounds.equals(photoBounds)) { return true; } |
