summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2013-05-07 22:08:31 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-05-07 22:08:31 +0000
commit59733de14afde5e9c1b34dd72f40837e486e43b4 (patch)
treea07b11cf3aa8330c24dc2b78e489ad4b2028c293 /src/com/android
parentc9a1195c43d7d9953b3060503188c1f28cd948b8 (diff)
parent559970b1af0333ead040b68cbcc632072f2e7a76 (diff)
downloadandroid_packages_apps_Snap-59733de14afde5e9c1b34dd72f40837e486e43b4.tar.gz
android_packages_apps_Snap-59733de14afde5e9c1b34dd72f40837e486e43b4.tar.bz2
android_packages_apps_Snap-59733de14afde5e9c1b34dd72f40837e486e43b4.zip
Merge "Avoid rounding errors from cropping uncropped images." into gb-ub-photos-bryce
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java28
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java2
2 files changed, 27 insertions, 3 deletions
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
index 898fdf021..e5820a8f2 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
@@ -140,8 +140,21 @@ public class GeometryMetadata extends FilterRepresentation {
float scale = 1.0f;
scale = GeometryMath.scale(mPhotoBounds.width(), mPhotoBounds.height(), bitmap.getWidth(),
bitmap.getHeight());
- return new RectF(mCropBounds.left * scale, mCropBounds.top * scale,
+ RectF croppedRegion = new RectF(mCropBounds.left * scale, mCropBounds.top * scale,
mCropBounds.right * scale, mCropBounds.bottom * scale);
+
+ // If no crop has been applied, make sure to use the exact size values.
+ // Multiplying using scale will introduce rounding errors that modify
+ // even un-cropped images.
+ if (mCropBounds.left == 0 && mCropBounds.right == mPhotoBounds.right) {
+ croppedRegion.left = 0;
+ croppedRegion.right = bitmap.getWidth();
+ }
+ if (mCropBounds.top == 0 && mCropBounds.bottom == mPhotoBounds.bottom) {
+ croppedRegion.top = 0;
+ croppedRegion.bottom = bitmap.getHeight();
+ }
+ return croppedRegion;
}
public FLIP getFlipType() {
@@ -375,11 +388,22 @@ public class GeometryMetadata extends FilterRepresentation {
public Matrix buildTotalXform(float bmWidth, float bmHeight, float[] displayCenter) {
RectF rp = getPhotoBounds();
RectF rc = getPreviewCropBounds();
-
float scale = GeometryMath.scale(rp.width(), rp.height(), bmWidth, bmHeight);
RectF scaledCrop = GeometryMath.scaleRect(rc, scale);
RectF scaledPhoto = GeometryMath.scaleRect(rp, scale);
+ // If no crop has been applied, make sure to use the exact size values.
+ // Multiplying using scale will introduce rounding errors that modify
+ // even un-cropped images.
+ if (rc.left == 0 && rc.right == rp.right) {
+ scaledCrop.left = scaledPhoto.left = 0;
+ scaledCrop.right = scaledPhoto.right = bmWidth;
+ }
+ if (rc.top == 0 && rc.bottom == rp.bottom) {
+ scaledCrop.top = scaledPhoto.top = 0;
+ scaledCrop.bottom = scaledPhoto.bottom = bmHeight;
+ }
+
Matrix m1 = GeometryMetadata.buildWanderingCropMatrix(scaledPhoto, scaledCrop,
getRotation(), getStraightenRotation(),
getFlipType(), displayCenter);
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index ed0a72a33..2a7e601ee 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -194,7 +194,7 @@ public class ImagePreset {
}
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation filter = mFilters.elementAt(i);
- if (!filter.isNil()) {
+ if (!filter.isNil() && !filter.getName().equalsIgnoreCase("none")) {
return true;
}
}