summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-10-22 15:20:55 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-22 15:20:56 -0700
commitbc912f9e17b55ab815bd12081e1ceb71a2c9f424 (patch)
tree2438cdf9f24b89dba058bb300aed08c25d34eb13
parent3651c39f614e37cbf35896838bf56bacd6423266 (diff)
parente1c830b5b51ad4760d2730227d89b9326dfc48b6 (diff)
downloadandroid_packages_apps_Snap-bc912f9e17b55ab815bd12081e1ceb71a2c9f424.tar.gz
android_packages_apps_Snap-bc912f9e17b55ab815bd12081e1ceb71a2c9f424.tar.bz2
android_packages_apps_Snap-bc912f9e17b55ab815bd12081e1ceb71a2c9f424.zip
Merge "Fix geometry xforms & minor bug." into gb-ub-photos-arches
-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;
}
}