summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-10-18 23:39:18 -0700
committerRuben Brunk <rubenbrunk@google.com>2012-10-22 13:09:35 -0700
commite1c830b5b51ad4760d2730227d89b9326dfc48b6 (patch)
treefb9efdb2e28049718ea4f25ae8bc2bafd42dc28e
parent2f7d7b23ff41800d01edad9d30ddd9517b309e18 (diff)
downloadandroid_packages_apps_Snap-e1c830b5b51ad4760d2730227d89b9326dfc48b6.tar.gz
android_packages_apps_Snap-e1c830b5b51ad4760d2730227d89b9326dfc48b6.tar.bz2
android_packages_apps_Snap-e1c830b5b51ad4760d2730227d89b9326dfc48b6.zip
Fix geometry xforms & minor bug.
Bug: 7376048 Fixed geometry transform. Fixed minor bug where the foldername for saved edited images was incorrect. Change-Id: I901df11cf71cd987b354dd7821fef7a484b0cbd3
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java19
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java14
2 files changed, 8 insertions, 25 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
index 2c7ed2dd8..04057681f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java
@@ -63,21 +63,6 @@ public class ImageFilterGeometry extends ImageFilter {
native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight,
Bitmap dst, int dstWidth, int dstHeight, float straightenAngle);
- public Matrix buildMatrix(RectF r) {
- float dx = r.width() / 2;
- float dy = r.height() / 2;
- if (mGeometry.hasSwitchedWidthHeight()) {
- float temp = dx;
- dx = dy;
- dy = temp;
- }
- float w = r.left * 2 + r.width();
- float h = r.top * 2 + r.height();
- Matrix m = mGeometry.buildGeometryMatrix(w, h, 1f, dx, dy, false);
-
- return m;
- }
-
@Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
// TODO: implement bilinear or bicubic here... for now, just use
@@ -94,16 +79,12 @@ public class ImageFilterGeometry extends ImageFilter {
temp = Bitmap.createBitmap(cropBounds.width(), cropBounds.height(), mConfig);
}
- Matrix drawMatrix = buildMatrix(crop);
- /*
RectF rp = mGeometry.getPhotoBounds();
RectF rc = mGeometry.getPreviewCropBounds();
- // TODO: fix this method instead of calling the above buildMatrix()
Matrix drawMatrix = mGeometry.buildTotalXform(rp.width(), rp.height(), rc.width(),
rc.height(), rc.left, rc.top,
mGeometry.getRotation(), mGeometry.getStraightenRotation(),
bitmap.getWidth() / rp.width(), null);
- */
Canvas canvas = new Canvas(temp);
Paint paint = new Paint();
paint.setAntiAlias(true);
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
index 666eff99e..58c6f6fde 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java
@@ -242,18 +242,20 @@ public class GeometryMetadata {
public Matrix buildTotalXform(float pwidth, float pheight, float cwidth, float cheight,
float cleft, float ctop, float rotation, float straighten, float scale, RectF dst) {
- Matrix m = getFlipMatrix(pwidth, pheight);
- m.postRotate(rotation + straighten, pwidth / 2, pheight / 2);
- Matrix m1 = new Matrix();
- m1.setRotate(rotation, pwidth / 2, pheight / 2);
+ float s_pwidth = pwidth * scale;
+ float s_pheight = pheight * scale;
+ Matrix m = getFlipMatrix(s_pwidth, s_pheight);
+ m.postRotate(rotation + straighten, s_pwidth / 2, s_pheight / 2);
+ Matrix m1 = getFlipMatrix(s_pwidth, s_pheight);
+ m1.postRotate(rotation, s_pwidth / 2, s_pheight / 2);
// find new top left for crop.
- RectF crop = new RectF(cleft, ctop, cleft + cwidth, ctop + cheight);
+ RectF crop = new RectF(cleft * scale, ctop * scale, (cleft + cwidth) * scale,
+ (ctop + cheight) * scale);
if (!m1.mapRect(crop))
return null;
if (dst != null)
dst.set(crop);
m.postTranslate(-crop.left, -crop.top);
- m.postScale(scale, scale);
return m;
}
}