I want to rotate an ImageView image. Here is my code:
Matrix mat = new Matrix();
mat.preRotate(90, ivImage.getWidth()/2, ivImage.getHeight()/2);
ivImage.setScaleType(ScaleType.MATRIX);
ivImage.setImageMatrix(mat);
but when I click on the rotate button, not only the image rotates, but it is scaled too, because the bitmap is larger then the ImageView
.
I know I can use
b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), mat, true);
ivImage.setImageBitmap(b);
but this is noticeably slower, and has some lag.
So my question is: how to rotate the image without being scaled and without recreating the bitmap?