Loading res/layout/filtershow_activity.xml +0 −2 Original line number Original line Diff line number Diff line Loading @@ -115,13 +115,11 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> android:visibility="gone" /> <!-- <com.android.gallery3d.filtershow.imageshow.ImageCrop <com.android.gallery3d.filtershow.imageshow.ImageCrop android:id="@+id/imageCrop" android:id="@+id/imageCrop" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> android:visibility="gone" /> --> <com.android.gallery3d.filtershow.imageshow.ImageRotate <com.android.gallery3d.filtershow.imageshow.ImageRotate android:id="@+id/imageRotate" android:id="@+id/imageRotate" Loading src/com/android/gallery3d/filtershow/FilterShowActivity.java +7 −12 Original line number Original line Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, private ImageBorder mImageBorders = null; private ImageBorder mImageBorders = null; private ImageStraighten mImageStraighten = null; private ImageStraighten mImageStraighten = null; private ImageZoom mImageZoom = null; private ImageZoom mImageZoom = null; private final ImageCrop mImageCrop = null; private ImageCrop mImageCrop = null; private ImageRotate mImageRotate = null; private ImageRotate mImageRotate = null; private ImageFlip mImageFlip = null; private ImageFlip mImageFlip = null; Loading Loading @@ -140,8 +140,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageBorders = (ImageBorder) findViewById(R.id.imageBorder); mImageBorders = (ImageBorder) findViewById(R.id.imageBorder); mImageStraighten = (ImageStraighten) findViewById(R.id.imageStraighten); mImageStraighten = (ImageStraighten) findViewById(R.id.imageStraighten); mImageZoom = (ImageZoom) findViewById(R.id.imageZoom); mImageZoom = (ImageZoom) findViewById(R.id.imageZoom); // TODO: implement crop mImageCrop = (ImageCrop) findViewById(R.id.imageCrop); // mImageCrop = (ImageCrop) findViewById(R.id.imageCrop); mImageRotate = (ImageRotate) findViewById(R.id.imageRotate); mImageRotate = (ImageRotate) findViewById(R.id.imageRotate); mImageFlip = (ImageFlip) findViewById(R.id.imageFlip); mImageFlip = (ImageFlip) findViewById(R.id.imageFlip); Loading @@ -150,8 +149,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageViews.add(mImageBorders); mImageViews.add(mImageBorders); mImageViews.add(mImageStraighten); mImageViews.add(mImageStraighten); mImageViews.add(mImageZoom); mImageViews.add(mImageZoom); // TODO: implement crop mImageViews.add(mImageCrop); // mImageViews.add(mImageCrop); mImageViews.add(mImageRotate); mImageViews.add(mImageRotate); mImageViews.add(mImageFlip); mImageViews.add(mImageFlip); Loading Loading @@ -180,9 +178,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageStraighten.setMaster(mImageShow); mImageStraighten.setMaster(mImageShow); mImageZoom.setImageLoader(mImageLoader); mImageZoom.setImageLoader(mImageLoader); mImageZoom.setMaster(mImageShow); mImageZoom.setMaster(mImageShow); // TODO: implement crop mImageCrop.setImageLoader(mImageLoader); // mImageCrop.setImageLoader(mImageLoader); mImageCrop.setMaster(mImageShow); // mImageCrop.setMaster(mImageShow); mImageRotate.setImageLoader(mImageLoader); mImageRotate.setImageLoader(mImageLoader); mImageRotate.setMaster(mImageShow); mImageRotate.setMaster(mImageShow); mImageFlip.setImageLoader(mImageLoader); mImageFlip.setImageLoader(mImageLoader); Loading @@ -192,8 +189,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addImageView(findViewById(R.id.imageCurves)); mPanelController.addImageView(findViewById(R.id.imageCurves)); mPanelController.addImageView(findViewById(R.id.imageBorder)); mPanelController.addImageView(findViewById(R.id.imageBorder)); mPanelController.addImageView(findViewById(R.id.imageStraighten)); mPanelController.addImageView(findViewById(R.id.imageStraighten)); // TODO: implement crop mPanelController.addImageView(findViewById(R.id.imageCrop)); // mPanelController.addImageView(findViewById(R.id.imageCrop)); mPanelController.addImageView(findViewById(R.id.imageRotate)); mPanelController.addImageView(findViewById(R.id.imageRotate)); mPanelController.addImageView(findViewById(R.id.imageFlip)); mPanelController.addImageView(findViewById(R.id.imageFlip)); mPanelController.addImageView(findViewById(R.id.imageZoom)); mPanelController.addImageView(findViewById(R.id.imageZoom)); Loading @@ -203,8 +199,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addPanel(mGeometryButton, mListGeometry, 2); mPanelController.addPanel(mGeometryButton, mListGeometry, 2); mPanelController.addComponent(mGeometryButton, findViewById(R.id.straightenButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.straightenButton)); // TODO: implement crop mPanelController.addComponent(mGeometryButton, findViewById(R.id.cropButton)); // mPanelController.addComponent(mGeometryButton, findViewById(R.id.cropButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.rotateButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.rotateButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton)); Loading src/com/android/gallery3d/filtershow/PanelController.java +1 −4 Original line number Original line Diff line number Diff line Loading @@ -400,16 +400,13 @@ public class PanelController implements OnClickListener { mUtilityPanel.setEffectName(ename); mUtilityPanel.setEffectName(ename); break; break; } } /* // TODO: implement crop case R.id.cropButton: { case R.id.cropButton: { mCurrentImage = showImageView(R.id.imageCrop); mCurrentImage = showImageView(R.id.imageCrop); String ename = mCurrentImage.getContext().getString(R.string.crop); String ename = mCurrentImage.getContext().getString(R.string.crop); mUtilityPanel.setEffectName(ename); mUtilityPanel.setEffectName(ename); mUtilityPanel.showParameter(false); mUtilityPanel.setShowParameter(false); break; break; } } */ case R.id.rotateButton: { case R.id.rotateButton: { mCurrentImage = showImageView(R.id.imageRotate); mCurrentImage = showImageView(R.id.imageRotate); String ename = mCurrentImage.getContext().getString(R.string.rotate); String ename = mCurrentImage.getContext().getString(R.string.rotate); Loading src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import com.android.gallery3d.filtershow.imageshow.GeometryMetadata; import com.android.gallery3d.filtershow.imageshow.GeometryMetadata; Loading Loading @@ -61,15 +63,18 @@ public class ImageFilterGeometry extends ImageFilter { native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight, native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight, Bitmap dst, int dstWidth, int dstHeight, float straightenAngle); Bitmap dst, int dstWidth, int dstHeight, float straightenAngle); public Matrix buildMatrix(Bitmap bitmap, boolean rotated) { public Matrix buildMatrix(RectF r) { float dx = bitmap.getWidth()/2; float dx = r.width()/2; float dy = bitmap.getHeight()/2; float dy = r.height()/2; if(mGeometry.hasSwitchedWidthHeight()){ if(mGeometry.hasSwitchedWidthHeight()){ float temp = dx; float temp = dx; dx = dy; dx = dy; dy = temp; dy = temp; } } Matrix m = mGeometry.buildGeometryMatrix(bitmap.getWidth(), bitmap.getHeight(), 1f/mGeometry.getScaleFactor(), dx, dy); 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; return m; } } Loading @@ -78,18 +83,18 @@ public class ImageFilterGeometry extends ImageFilter { // TODO: implement bilinear or bicubic here... for now, just use // TODO: implement bilinear or bicubic here... for now, just use // canvas to do a simple implementation... // canvas to do a simple implementation... // TODO: and be more memory efficient! (do it in native?) // TODO: and be more memory efficient! (do it in native?) Rect cropBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF c = mGeometry.getCropBounds(); if(c != null && c.width() > 0 && c.height() > 0) c.roundOut(cropBounds); Bitmap temp = null; Bitmap temp = null; float rotation = mGeometry.getRotation(); if (mGeometry.hasSwitchedWidthHeight()) { boolean rotated = false; temp = Bitmap.createBitmap(cropBounds.height(), cropBounds.width(), mConfig); if (rotation == 0 || rotation % 180 == 0) { temp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), mConfig); } else { } else { temp = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getWidth(), mConfig); temp = Bitmap.createBitmap(cropBounds.width(), cropBounds.height(), mConfig); rotated = true; } } Matrix drawMatrix = buildMatrix(bitmap, rotated); Matrix drawMatrix = buildMatrix(c); Canvas canvas = new Canvas(temp); Canvas canvas = new Canvas(temp); canvas.drawBitmap(bitmap, drawMatrix, new Paint()); canvas.drawBitmap(bitmap, drawMatrix, new Paint()); return temp; return temp; Loading src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java +18 −13 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ public class GeometryMetadata { private final RectF mPhotoBounds = new RectF(); private final RectF mPhotoBounds = new RectF(); private FLIP mFlip = FLIP.NONE; private FLIP mFlip = FLIP.NONE; private RectF mBounds = new RectF(); private RectF mBounds = new RectF(); public enum FLIP { public enum FLIP { Loading Loading @@ -87,7 +86,6 @@ public class GeometryMetadata { return new RectF(mPhotoBounds); return new RectF(mPhotoBounds); } } public void setScaleFactor(float scale) { public void setScaleFactor(float scale) { mScaleFactor = scale; mScaleFactor = scale; } } Loading Loading @@ -186,23 +184,30 @@ public class GeometryMetadata { return (((int) (mRotation / 90)) % 2) != 0; return (((int) (mRotation / 90)) % 2) != 0; } } public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy){ public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy, float rotation) { float dx0 = width / 2; float dx0 = width / 2; float dy0 = height / 2; float dy0 = height / 2; Matrix m = getFlipMatrix(width, height); Matrix m = getFlipMatrix(width, height); m.postTranslate(-dx0, -dy0); m.postTranslate(-dx0, -dy0); float rot = mRotation % 360; m.postRotate(rotation); if (rot < 0) rot += 360; m.postRotate(rot + mStraightenRotation); m.postScale(scaling, scaling); m.postScale(scaling, scaling); m.postTranslate(dx, dy); m.postTranslate(dx, dy); return m; return m; } } public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy, boolean onlyRotate) { float rot = mRotation; if (!onlyRotate) { rot += mStraightenRotation; } return buildGeometryMatrix(width, height, scaling, dx, dy, rot); } public Matrix buildGeometryUIMatrix(float scaling, float dx, float dy) { public Matrix buildGeometryUIMatrix(float scaling, float dx, float dy) { float w = mPhotoBounds.width(); float w = mPhotoBounds.width(); float h = mPhotoBounds.height(); float h = mPhotoBounds.height(); return buildGeometryMatrix(w, h, scaling, dx, dy); return buildGeometryMatrix(w, h, scaling, dx, dy, false); } } } } Loading
res/layout/filtershow_activity.xml +0 −2 Original line number Original line Diff line number Diff line Loading @@ -115,13 +115,11 @@ android:layout_height="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> android:visibility="gone" /> <!-- <com.android.gallery3d.filtershow.imageshow.ImageCrop <com.android.gallery3d.filtershow.imageshow.ImageCrop android:id="@+id/imageCrop" android:id="@+id/imageCrop" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_height="wrap_content" android:visibility="gone" /> android:visibility="gone" /> --> <com.android.gallery3d.filtershow.imageshow.ImageRotate <com.android.gallery3d.filtershow.imageshow.ImageRotate android:id="@+id/imageRotate" android:id="@+id/imageRotate" Loading
src/com/android/gallery3d/filtershow/FilterShowActivity.java +7 −12 Original line number Original line Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, private ImageBorder mImageBorders = null; private ImageBorder mImageBorders = null; private ImageStraighten mImageStraighten = null; private ImageStraighten mImageStraighten = null; private ImageZoom mImageZoom = null; private ImageZoom mImageZoom = null; private final ImageCrop mImageCrop = null; private ImageCrop mImageCrop = null; private ImageRotate mImageRotate = null; private ImageRotate mImageRotate = null; private ImageFlip mImageFlip = null; private ImageFlip mImageFlip = null; Loading Loading @@ -140,8 +140,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageBorders = (ImageBorder) findViewById(R.id.imageBorder); mImageBorders = (ImageBorder) findViewById(R.id.imageBorder); mImageStraighten = (ImageStraighten) findViewById(R.id.imageStraighten); mImageStraighten = (ImageStraighten) findViewById(R.id.imageStraighten); mImageZoom = (ImageZoom) findViewById(R.id.imageZoom); mImageZoom = (ImageZoom) findViewById(R.id.imageZoom); // TODO: implement crop mImageCrop = (ImageCrop) findViewById(R.id.imageCrop); // mImageCrop = (ImageCrop) findViewById(R.id.imageCrop); mImageRotate = (ImageRotate) findViewById(R.id.imageRotate); mImageRotate = (ImageRotate) findViewById(R.id.imageRotate); mImageFlip = (ImageFlip) findViewById(R.id.imageFlip); mImageFlip = (ImageFlip) findViewById(R.id.imageFlip); Loading @@ -150,8 +149,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageViews.add(mImageBorders); mImageViews.add(mImageBorders); mImageViews.add(mImageStraighten); mImageViews.add(mImageStraighten); mImageViews.add(mImageZoom); mImageViews.add(mImageZoom); // TODO: implement crop mImageViews.add(mImageCrop); // mImageViews.add(mImageCrop); mImageViews.add(mImageRotate); mImageViews.add(mImageRotate); mImageViews.add(mImageFlip); mImageViews.add(mImageFlip); Loading Loading @@ -180,9 +178,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mImageStraighten.setMaster(mImageShow); mImageStraighten.setMaster(mImageShow); mImageZoom.setImageLoader(mImageLoader); mImageZoom.setImageLoader(mImageLoader); mImageZoom.setMaster(mImageShow); mImageZoom.setMaster(mImageShow); // TODO: implement crop mImageCrop.setImageLoader(mImageLoader); // mImageCrop.setImageLoader(mImageLoader); mImageCrop.setMaster(mImageShow); // mImageCrop.setMaster(mImageShow); mImageRotate.setImageLoader(mImageLoader); mImageRotate.setImageLoader(mImageLoader); mImageRotate.setMaster(mImageShow); mImageRotate.setMaster(mImageShow); mImageFlip.setImageLoader(mImageLoader); mImageFlip.setImageLoader(mImageLoader); Loading @@ -192,8 +189,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addImageView(findViewById(R.id.imageCurves)); mPanelController.addImageView(findViewById(R.id.imageCurves)); mPanelController.addImageView(findViewById(R.id.imageBorder)); mPanelController.addImageView(findViewById(R.id.imageBorder)); mPanelController.addImageView(findViewById(R.id.imageStraighten)); mPanelController.addImageView(findViewById(R.id.imageStraighten)); // TODO: implement crop mPanelController.addImageView(findViewById(R.id.imageCrop)); // mPanelController.addImageView(findViewById(R.id.imageCrop)); mPanelController.addImageView(findViewById(R.id.imageRotate)); mPanelController.addImageView(findViewById(R.id.imageRotate)); mPanelController.addImageView(findViewById(R.id.imageFlip)); mPanelController.addImageView(findViewById(R.id.imageFlip)); mPanelController.addImageView(findViewById(R.id.imageZoom)); mPanelController.addImageView(findViewById(R.id.imageZoom)); Loading @@ -203,8 +199,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener, mPanelController.addPanel(mGeometryButton, mListGeometry, 2); mPanelController.addPanel(mGeometryButton, mListGeometry, 2); mPanelController.addComponent(mGeometryButton, findViewById(R.id.straightenButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.straightenButton)); // TODO: implement crop mPanelController.addComponent(mGeometryButton, findViewById(R.id.cropButton)); // mPanelController.addComponent(mGeometryButton, findViewById(R.id.cropButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.rotateButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.rotateButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton)); mPanelController.addComponent(mGeometryButton, findViewById(R.id.flipButton)); Loading
src/com/android/gallery3d/filtershow/PanelController.java +1 −4 Original line number Original line Diff line number Diff line Loading @@ -400,16 +400,13 @@ public class PanelController implements OnClickListener { mUtilityPanel.setEffectName(ename); mUtilityPanel.setEffectName(ename); break; break; } } /* // TODO: implement crop case R.id.cropButton: { case R.id.cropButton: { mCurrentImage = showImageView(R.id.imageCrop); mCurrentImage = showImageView(R.id.imageCrop); String ename = mCurrentImage.getContext().getString(R.string.crop); String ename = mCurrentImage.getContext().getString(R.string.crop); mUtilityPanel.setEffectName(ename); mUtilityPanel.setEffectName(ename); mUtilityPanel.showParameter(false); mUtilityPanel.setShowParameter(false); break; break; } } */ case R.id.rotateButton: { case R.id.rotateButton: { mCurrentImage = showImageView(R.id.imageRotate); mCurrentImage = showImageView(R.id.imageRotate); String ename = mCurrentImage.getContext().getString(R.string.rotate); String ename = mCurrentImage.getContext().getString(R.string.rotate); Loading
src/com/android/gallery3d/filtershow/filters/ImageFilterGeometry.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import com.android.gallery3d.filtershow.imageshow.GeometryMetadata; import com.android.gallery3d.filtershow.imageshow.GeometryMetadata; Loading Loading @@ -61,15 +63,18 @@ public class ImageFilterGeometry extends ImageFilter { native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight, native protected void nativeApplyFilterStraighten(Bitmap src, int srcWidth, int srcHeight, Bitmap dst, int dstWidth, int dstHeight, float straightenAngle); Bitmap dst, int dstWidth, int dstHeight, float straightenAngle); public Matrix buildMatrix(Bitmap bitmap, boolean rotated) { public Matrix buildMatrix(RectF r) { float dx = bitmap.getWidth()/2; float dx = r.width()/2; float dy = bitmap.getHeight()/2; float dy = r.height()/2; if(mGeometry.hasSwitchedWidthHeight()){ if(mGeometry.hasSwitchedWidthHeight()){ float temp = dx; float temp = dx; dx = dy; dx = dy; dy = temp; dy = temp; } } Matrix m = mGeometry.buildGeometryMatrix(bitmap.getWidth(), bitmap.getHeight(), 1f/mGeometry.getScaleFactor(), dx, dy); 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; return m; } } Loading @@ -78,18 +83,18 @@ public class ImageFilterGeometry extends ImageFilter { // TODO: implement bilinear or bicubic here... for now, just use // TODO: implement bilinear or bicubic here... for now, just use // canvas to do a simple implementation... // canvas to do a simple implementation... // TODO: and be more memory efficient! (do it in native?) // TODO: and be more memory efficient! (do it in native?) Rect cropBounds = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF c = mGeometry.getCropBounds(); if(c != null && c.width() > 0 && c.height() > 0) c.roundOut(cropBounds); Bitmap temp = null; Bitmap temp = null; float rotation = mGeometry.getRotation(); if (mGeometry.hasSwitchedWidthHeight()) { boolean rotated = false; temp = Bitmap.createBitmap(cropBounds.height(), cropBounds.width(), mConfig); if (rotation == 0 || rotation % 180 == 0) { temp = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), mConfig); } else { } else { temp = Bitmap.createBitmap(bitmap.getHeight(), bitmap.getWidth(), mConfig); temp = Bitmap.createBitmap(cropBounds.width(), cropBounds.height(), mConfig); rotated = true; } } Matrix drawMatrix = buildMatrix(bitmap, rotated); Matrix drawMatrix = buildMatrix(c); Canvas canvas = new Canvas(temp); Canvas canvas = new Canvas(temp); canvas.drawBitmap(bitmap, drawMatrix, new Paint()); canvas.drawBitmap(bitmap, drawMatrix, new Paint()); return temp; return temp; Loading
src/com/android/gallery3d/filtershow/imageshow/GeometryMetadata.java +18 −13 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ public class GeometryMetadata { private final RectF mPhotoBounds = new RectF(); private final RectF mPhotoBounds = new RectF(); private FLIP mFlip = FLIP.NONE; private FLIP mFlip = FLIP.NONE; private RectF mBounds = new RectF(); private RectF mBounds = new RectF(); public enum FLIP { public enum FLIP { Loading Loading @@ -87,7 +86,6 @@ public class GeometryMetadata { return new RectF(mPhotoBounds); return new RectF(mPhotoBounds); } } public void setScaleFactor(float scale) { public void setScaleFactor(float scale) { mScaleFactor = scale; mScaleFactor = scale; } } Loading Loading @@ -186,23 +184,30 @@ public class GeometryMetadata { return (((int) (mRotation / 90)) % 2) != 0; return (((int) (mRotation / 90)) % 2) != 0; } } public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy){ public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy, float rotation) { float dx0 = width / 2; float dx0 = width / 2; float dy0 = height / 2; float dy0 = height / 2; Matrix m = getFlipMatrix(width, height); Matrix m = getFlipMatrix(width, height); m.postTranslate(-dx0, -dy0); m.postTranslate(-dx0, -dy0); float rot = mRotation % 360; m.postRotate(rotation); if (rot < 0) rot += 360; m.postRotate(rot + mStraightenRotation); m.postScale(scaling, scaling); m.postScale(scaling, scaling); m.postTranslate(dx, dy); m.postTranslate(dx, dy); return m; return m; } } public Matrix buildGeometryMatrix(float width, float height, float scaling, float dx, float dy, boolean onlyRotate) { float rot = mRotation; if (!onlyRotate) { rot += mStraightenRotation; } return buildGeometryMatrix(width, height, scaling, dx, dy, rot); } public Matrix buildGeometryUIMatrix(float scaling, float dx, float dy) { public Matrix buildGeometryUIMatrix(float scaling, float dx, float dy) { float w = mPhotoBounds.width(); float w = mPhotoBounds.width(); float h = mPhotoBounds.height(); float h = mPhotoBounds.height(); return buildGeometryMatrix(w, h, scaling, dx, dy); return buildGeometryMatrix(w, h, scaling, dx, dy, false); } } } }