Search code examples
androidbitmaprotationdrawbitmap

How to rotate a bitmap when drawing a subset of it?


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.


Solution

  • 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.