diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2012-10-09 13:48:10 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-09 13:48:10 -0700 |
commit | c7bf12b9d336b73ea7885294da1029147c6e67a6 (patch) | |
tree | e2178683978b09c6e0103d26b8624fe834c205d0 | |
parent | 8a3f6f388a1d15ec12ebfe1c1dcfb52597cb92c7 (diff) | |
parent | 0310f3a4a196ac660657746ae03bb789a0835e71 (diff) | |
download | android_packages_apps_Snap-c7bf12b9d336b73ea7885294da1029147c6e67a6.tar.gz android_packages_apps_Snap-c7bf12b9d336b73ea7885294da1029147c6e67a6.tar.bz2 android_packages_apps_Snap-c7bf12b9d336b73ea7885294da1029147c6e67a6.zip |
Merge "Implementing Geometry save operations." into gb-ub-photos-arches
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java index 1368255a6..311ae6310 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java @@ -35,6 +35,9 @@ public class ImageFilterGeometry extends ImageFilter { private static final int BOTH = 3; private static final int VERTICAL = 2; private static final int HORIZONTAL = 1; + private static final int NINETY = 1; + private static final int ONE_EIGHTY = 2; + private static final int TWO_SEVENTY = 3; public ImageFilterGeometry() { mName = "Geometry"; @@ -54,7 +57,7 @@ public class ImageFilterGeometry extends ImageFilter { Bitmap dst, int dstWidth, int dstHeight, int flip); native protected void nativeApplyFilterRotate(Bitmap src, int srcWidth, int srcHeight, - Bitmap dst, int dstWidth, int dstHeight, float rotate); + Bitmap dst, int dstWidth, int dstHeight, int rotate); native protected void nativeApplyFilterCrop(Bitmap src, int srcWidth, int srcHeight, Bitmap dst, int dstWidth, int dstHeight, int offsetWidth, int offsetHeight); @@ -111,15 +114,21 @@ public class ImageFilterGeometry extends ImageFilter { if (rotate) { // Fails for non-90 degree rotations Bitmap modBitmapRotate = null; - if (((int) (sAngle / 90)) % 2 == 0) { + rAngle %= 360; + int deg = (int) (rAngle / 90); + deg = -deg; // Make CCW positive + if (deg < 0) + deg += 4; + // Now deg is in [1, 3] as required by native rotate + if (deg == ONE_EIGHTY) { modBitmapRotate = Bitmap.createBitmap(bmWidth, bmHeight, mConfig); nativeApplyFilterRotate(modBitmap, bmWidth, bmHeight, modBitmapRotate, - bmWidth, bmHeight, mGeometry.getRotation()); + bmWidth, bmHeight, deg); modifiedBounds = new Rect(0, 0, bmWidth, bmHeight); - } else { + } else if (deg == TWO_SEVENTY || deg == NINETY) { modBitmapRotate = Bitmap.createBitmap(bmHeight, bmWidth, mConfig); nativeApplyFilterRotate(modBitmap, bmWidth, bmHeight, modBitmapRotate, - bmHeight, bmWidth, mGeometry.getRotation()); + bmHeight, bmWidth, deg); modifiedBounds = new Rect(0, 0, bmHeight, bmWidth); } modBitmap = modBitmapRotate; |