From 267c4c6a513671441031a9c21839995aecc4fc52 Mon Sep 17 00:00:00 2001 From: nicolasroard Date: Sun, 21 Oct 2012 12:58:59 -0700 Subject: [PATCH] Revert partially CL https://googleplex-android-review.googlesource.com/#/c/243614/ bug:7384984 Change-Id: Id10c7ac08cc7aab4d2f4b19c88b20d0f3369807a --- .../filtershow/filters/ImageFilterGeometry.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java index b5b505f55..b9c94b634 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java @@ -63,6 +63,21 @@ 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 @@ -79,12 +94,16 @@ 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); canvas.drawBitmap(bitmap, drawMatrix, new Paint()); return temp; -- 2.11.0