Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to rotate a bitmap 90 degrees

Tags:

android

There is a statement in android canvas.drawBitmap(visiblePage, 0, 0, paint);

When I add canvas.rotate(90), there is no effect. But if I write

canvas.rotate(90) canvas.drawBitmap(visiblePage, 0, 0, paint); 

I get no bitmap drawn. So what am I not doing right?

like image 364
murli Avatar asked Jan 26 '12 08:01

murli


People also ask

How do I rotate a picture on android?

To change the photo's perspective, tap Transform . Drag the dots to the edges of your desired photo or tap Auto. To rotate a photo 90 degrees, tap Rotate . To make minor adjustments to straighten the photo, use the dial above Rotate .


1 Answers

You can also try this one

Matrix matrix = new Matrix();  matrix.postRotate(90);  Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmapOrg, width, height, true);  Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, scaledBitmap.getWidth(), scaledBitmap.getHeight(), matrix, true); 

Then you can use the rotated image to set in your imageview through

imageView.setImageBitmap(rotatedBitmap); 
like image 168
Aryan Avatar answered Oct 11 '22 11:10

Aryan