diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2012-11-28 15:46:18 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-11-28 15:46:18 -0800 |
commit | 9dd37b67274b9ea68a06abfd0678d2fdcd596dab (patch) | |
tree | e514be34e4c9471d2cd2dacfb1dba022b5e691f8 | |
parent | a938efc8bd7ea589f74f247480db6909f2bbb835 (diff) | |
parent | 6a94446de01e8b6b034cc537ee3e65d507d47a47 (diff) | |
download | android_packages_apps_Gallery2-9dd37b67274b9ea68a06abfd0678d2fdcd596dab.tar.gz android_packages_apps_Gallery2-9dd37b67274b9ea68a06abfd0678d2fdcd596dab.tar.bz2 android_packages_apps_Gallery2-9dd37b67274b9ea68a06abfd0678d2fdcd596dab.zip |
am 6a94446d: Minor fix for some FP rounding errors in crop.
* commit '6a94446de01e8b6b034cc537ee3e65d507d47a47':
Minor fix for some FP rounding errors in crop.
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; } |