summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-10-08 21:15:16 -0700
committerRuben Brunk <rubenbrunk@google.com>2012-10-09 13:21:31 -0700
commit0310f3a4a196ac660657746ae03bb789a0835e71 (patch)
tree585a2a2d05ee0e3ecb09c213a707ab65d36ddba1 /src
parent0f9ebfc80f2db3bcb0ecee9b77418d7d81c5956e (diff)
downloadandroid_packages_apps_Snap-0310f3a4a196ac660657746ae03bb789a0835e71.tar.gz
android_packages_apps_Snap-0310f3a4a196ac660657746ae03bb789a0835e71.tar.bz2
android_packages_apps_Snap-0310f3a4a196ac660657746ae03bb789a0835e71.zip
Implementing Geometry save operations.
Bug: 7224232 Bug: 7218935 Change-Id: I83e5f8a5dc29c5b6be0bb69f10eadf823122bb97
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java19
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;