summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-10-09 13:49:55 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-09 13:49:55 -0700
commit893fd5f78cd3cfd5801835145f2456693a6d4230 (patch)
treee245c9b658eb726b26958740933a759f84c16431
parent85cc1e4230c53bd33e12f2dc87ee396c6aa03733 (diff)
parentc7bf12b9d336b73ea7885294da1029147c6e67a6 (diff)
downloadandroid_packages_apps_Snap-893fd5f78cd3cfd5801835145f2456693a6d4230.tar.gz
android_packages_apps_Snap-893fd5f78cd3cfd5801835145f2456693a6d4230.tar.bz2
android_packages_apps_Snap-893fd5f78cd3cfd5801835145f2456693a6d4230.zip
am bd14e827: Merge "Implementing Geometry save operations." into gb-ub-photos-arches
* commit 'bd14e82756742a67f3a6dfe5d1f93d7ae5cadef0': Implementing Geometry save operations.
-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;