天天看点

createbitmap 旋转90度_如何旋转的位图90度

createbitmap 旋转90度_如何旋转的位图90度

here is the statement in android

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

Now 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?

解决方案

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);