I have succesfully flipped a bitmap horizontally
mMirror.preScale(-1.0f, 1.0f);`
and vertically
mFlip.setScale(-1, 1);
mFlip.postTranslate(bitmap.getWidth(), 0);
How do i revert these actions?
I have succesfully flipped a bitmap horizontally
mMirror.preScale(-1.0f, 1.0f);`
and vertically
mFlip.setScale(-1, 1);
mFlip.postTranslate(bitmap.getWidth(), 0);
How do i revert these actions?
EDIT: you can try animations
final ObjectAnimator rotate = ObjectAnimator.ofFloat(imageview,
"rotationY", 0f, 180f);
rotate.setDuration(500); /* Duration for flipping the image */
rotate.setRepeatCount(0);
rotate.setInterpolator(new AccelerateDecelerateInterpolator());
rotate.start();
in case of undo change rotation values to 180,360
final ObjectAnimator rotate = ObjectAnimator.ofFloat(imagemain,
"rotationY", 180f, 360f);
rotate.setDuration(500); /* Duration for flipping the image */
rotate.setRepeatCount(0);
rotate.setInterpolator(new AccelerateDecelerateInterpolator());
rotate.start();
Previous answer: You should again call these methods to undo the changes... or you can take help from this method:
public static final int FLIP_VERTICAL = 1;
public static final int FLIP_HORIZONTAL = 2;
public Bitmap flipImage(Bitmap src, int type) {
// create new matrix for transformation
Matrix matrix = new Matrix();
// if vertical
if (type == FLIP_VERTICAL) {
// y = y * -1
matrix.preScale(1.0f, -1.0f);
}
// if horizonal
else if (type == FLIP_HORIZONTAL) {
// x = x * -1
matrix.preScale(-1.0f, 1.0f);
// unknown type
} else {
return null;
}
// return transformed image
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(),
matrix, true);
}
You can flip your bitmap vertically or horizontally by putting the type in the arguments and restore them to original by again calling that method.