0

I am using

pCanvas.drawBitmap(mBitmap, mRectSrc, mRectDst, mPainter);

to draw a subset of a bitmap. I wondering how I can rotate that bitmap without affecting the view. In my attempts, when I set the canvas to rotate the whole view (viewport) is rotated. This is not what I want.

4

2 回答 2

1

when I had to draw rotated text, I found the procedure is to call Canvas.save(), rotate (remembering that the center point remains the same), do the drawing and then call Canvas.restore(). I suppose it's just the same in this case.

于 2011-03-06T13:34:52.283 回答
0

Only way I know of is to use a Matrix. Try this pseudocode:

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.your_bitmap);
Matrix matrix = new Matrix();
matrix.postRotate(90);
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
于 2011-03-06T13:35:20.793 回答