Loading src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java +13 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import android.util.Log; import com.android.gallery3d.filtershow.cache.BitmapCache; import com.android.gallery3d.filtershow.cache.ImageLoader; Loading @@ -38,6 +39,9 @@ import java.util.Collection; import java.util.Iterator; public final class GeometryMathUtils { private static final String TAG = "GeometryMathUtils"; public static final float SHOW_SCALE = .9f; private GeometryMathUtils() {}; // Holder class for Geometry data. Loading Loading @@ -434,7 +438,15 @@ public final class GeometryMathUtils { public static Matrix getFullGeometryToScreenMatrix(GeometryHolder holder, int bitmapWidth, int bitmapHeight, int viewWidth, int viewHeight) { float scale = GeometryMathUtils.scale(bitmapWidth, bitmapHeight, viewWidth, viewHeight); int bh = bitmapHeight; int bw = bitmapWidth; if (GeometryMathUtils.needsDimensionSwap(holder.rotation)) { bh = bitmapWidth; bw = bitmapHeight; } float scale = GeometryMathUtils.scale(bw, bh, viewWidth, viewHeight); scale *= SHOW_SCALE; float s = Math.min(viewWidth / (float) bitmapWidth, viewHeight / (float) bitmapHeight); Matrix m = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight); m.postScale(scale, scale); m.postTranslate(viewWidth / 2f, viewHeight / 2f); Loading src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java +16 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,22 @@ public class ImageCrop extends ImageShow { // Scale min side and tolerance by display matrix scale factor mCropObj.setMinInnerSideSize(mDisplayMatrixInverse.mapRadius(mMinSideSize)); mCropObj.setTouchTolerance(mDisplayMatrixInverse.mapRadius(mTouchTolerance)); // drive Crop engine to clamp to crop bounds int[] sides = {CropObject.MOVE_TOP, CropObject.MOVE_BOTTOM, CropObject.MOVE_LEFT, CropObject.MOVE_RIGHT}; int delta = Math.min(canvas.getWidth(), canvas.getHeight()) / 4; int[] dy = {delta, -delta, 0, 0}; int[] dx = {0, 0, delta, -delta}; for (int i = 0; i < sides.length; i++) { mCropObj.selectEdge(sides[i]); mCropObj.moveCurrentSelection(dx[i], dy[i]); mCropObj.moveCurrentSelection(-dx[i], -dy[i]); } mCropObj.selectEdge(CropObject.MOVE_NONE); } // Draw actual bitmap mPaint.reset(); Loading src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java +15 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.graphics.RectF; import android.util.AttributeSet; import android.view.MotionEvent; import com.android.gallery3d.app.Log; import com.android.gallery3d.filtershow.editors.EditorStraighten; import com.android.gallery3d.filtershow.filters.FilterCropRepresentation; import com.android.gallery3d.filtershow.filters.FilterRepresentation; Loading Loading @@ -175,12 +176,25 @@ public class ImageStraighten extends ImageShow { private void updateCurrentCrop(Matrix m, GeometryHolder h, RectF tmp, int imageWidth, int imageHeight, int viewWidth, int viewHeight) { tmp.set(0, 0, imageHeight, imageWidth); m.mapRect(tmp); float top = tmp.top; float bottom = tmp.bottom; float left = tmp.left; float right = tmp.right; m.mapRect(tmp); int iw,ih; if (GeometryMathUtils.needsDimensionSwap(h.rotation)) { tmp.set(0, 0, imageHeight, imageWidth); iw = imageHeight; ih = imageWidth; } else { tmp.set(0, 0, imageWidth, imageHeight); iw = imageWidth; ih = imageHeight; } float scale = GeometryMathUtils.scale(imageWidth, imageHeight, viewWidth, viewHeight); float scale = GeometryMathUtils.scale(iw, ih, viewWidth, viewHeight); scale *= GeometryMathUtils.SHOW_SCALE; GeometryMathUtils.scaleRect(tmp, scale); getUntranslatedStraightenCropBounds(tmp, mAngle); tmp.offset(viewWidth / 2f - tmp.centerX(), viewHeight / 2f - tmp.centerY()); Loading Loading
src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java +13 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import android.util.Log; import com.android.gallery3d.filtershow.cache.BitmapCache; import com.android.gallery3d.filtershow.cache.ImageLoader; Loading @@ -38,6 +39,9 @@ import java.util.Collection; import java.util.Iterator; public final class GeometryMathUtils { private static final String TAG = "GeometryMathUtils"; public static final float SHOW_SCALE = .9f; private GeometryMathUtils() {}; // Holder class for Geometry data. Loading Loading @@ -434,7 +438,15 @@ public final class GeometryMathUtils { public static Matrix getFullGeometryToScreenMatrix(GeometryHolder holder, int bitmapWidth, int bitmapHeight, int viewWidth, int viewHeight) { float scale = GeometryMathUtils.scale(bitmapWidth, bitmapHeight, viewWidth, viewHeight); int bh = bitmapHeight; int bw = bitmapWidth; if (GeometryMathUtils.needsDimensionSwap(holder.rotation)) { bh = bitmapWidth; bw = bitmapHeight; } float scale = GeometryMathUtils.scale(bw, bh, viewWidth, viewHeight); scale *= SHOW_SCALE; float s = Math.min(viewWidth / (float) bitmapWidth, viewHeight / (float) bitmapHeight); Matrix m = getFullGeometryMatrix(holder, bitmapWidth, bitmapHeight); m.postScale(scale, scale); m.postTranslate(viewWidth / 2f, viewHeight / 2f); Loading
src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java +16 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,22 @@ public class ImageCrop extends ImageShow { // Scale min side and tolerance by display matrix scale factor mCropObj.setMinInnerSideSize(mDisplayMatrixInverse.mapRadius(mMinSideSize)); mCropObj.setTouchTolerance(mDisplayMatrixInverse.mapRadius(mTouchTolerance)); // drive Crop engine to clamp to crop bounds int[] sides = {CropObject.MOVE_TOP, CropObject.MOVE_BOTTOM, CropObject.MOVE_LEFT, CropObject.MOVE_RIGHT}; int delta = Math.min(canvas.getWidth(), canvas.getHeight()) / 4; int[] dy = {delta, -delta, 0, 0}; int[] dx = {0, 0, delta, -delta}; for (int i = 0; i < sides.length; i++) { mCropObj.selectEdge(sides[i]); mCropObj.moveCurrentSelection(dx[i], dy[i]); mCropObj.moveCurrentSelection(-dx[i], -dy[i]); } mCropObj.selectEdge(CropObject.MOVE_NONE); } // Draw actual bitmap mPaint.reset(); Loading
src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java +15 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.graphics.RectF; import android.util.AttributeSet; import android.view.MotionEvent; import com.android.gallery3d.app.Log; import com.android.gallery3d.filtershow.editors.EditorStraighten; import com.android.gallery3d.filtershow.filters.FilterCropRepresentation; import com.android.gallery3d.filtershow.filters.FilterRepresentation; Loading Loading @@ -175,12 +176,25 @@ public class ImageStraighten extends ImageShow { private void updateCurrentCrop(Matrix m, GeometryHolder h, RectF tmp, int imageWidth, int imageHeight, int viewWidth, int viewHeight) { tmp.set(0, 0, imageHeight, imageWidth); m.mapRect(tmp); float top = tmp.top; float bottom = tmp.bottom; float left = tmp.left; float right = tmp.right; m.mapRect(tmp); int iw,ih; if (GeometryMathUtils.needsDimensionSwap(h.rotation)) { tmp.set(0, 0, imageHeight, imageWidth); iw = imageHeight; ih = imageWidth; } else { tmp.set(0, 0, imageWidth, imageHeight); iw = imageWidth; ih = imageHeight; } float scale = GeometryMathUtils.scale(imageWidth, imageHeight, viewWidth, viewHeight); float scale = GeometryMathUtils.scale(iw, ih, viewWidth, viewHeight); scale *= GeometryMathUtils.SHOW_SCALE; GeometryMathUtils.scaleRect(tmp, scale); getUntranslatedStraightenCropBounds(tmp, mAngle); tmp.offset(viewWidth / 2f - tmp.centerX(), viewHeight / 2f - tmp.centerY()); Loading