summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-11-28 15:46:05 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-11-28 15:46:05 -0800
commit82b73d52e12b121b24ee685e71632483533246af (patch)
tree72d90b6e166a309656281af7d3548cbdab9b3b83 /src/com
parent0048915b4cea0196daa17dc69f7e10e9be9a4387 (diff)
parentd830f2a1b5becddfbae68e758fe29d6eda3777d8 (diff)
downloadandroid_packages_apps_Snap-82b73d52e12b121b24ee685e71632483533246af.tar.gz
android_packages_apps_Snap-82b73d52e12b121b24ee685e71632483533246af.tar.bz2
android_packages_apps_Snap-82b73d52e12b121b24ee685e71632483533246af.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/com')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java2
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMath.java7
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java6
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;
}