From 0310f3a4a196ac660657746ae03bb789a0835e71 Mon Sep 17 00:00:00 2001 From: Ruben Brunk Date: Mon, 8 Oct 2012 21:15:16 -0700 Subject: Implementing Geometry save operations. Bug: 7224232 Bug: 7218935 Change-Id: I83e5f8a5dc29c5b6be0bb69f10eadf823122bb97 --- .../filtershow/filters/ImageFilterGeometry.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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; -- cgit v1.2.3