Reputation: 71
I'm trying to rotate a bitmap in Android using the following function, the image is getting distorted with some degrees, like 70, how can I rotate an image without distorting it in any degree?
public Bitmap rotateBitmap (Bitmap bm, int degree) {
Matrix matrix = new Matrix();
matrix.setRotate(degree, bm.getWidth() / 2, bm.getHeight() / 2);
return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
}
Upvotes: 1
Views: 182
Reputation: 528
Hello there use this function!
public static Bitmap RotateBitmap(Bitmap source, float angle) {
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(),
source.getHeight(), matrix, true);
}
You can use this function like this :
Bitmap bmp : RotateBitmap(b,90);
Hope this works for you !:)
Upvotes: 1