I need some advice regarding efficient use of canvas and matrices
- I have a source bitmap "B0" loaded in memory, which is WxH
- I have a bitmap B1, onto which I draw with a canvas.
- There is a rotated (with an arbitrary angle) rectangular portion (w_p*h_p) of B0. I need to get this portion and draw it, once unrotated, onto B1
I would like to do it with normal Views, canvas and matrices. Not surfaceviews, not opengl
An "already working" approach is:
- Rotate the bitmap B0 to compensate for the selected zone rotation --> we get B0_r
- Calculate the translated rectangle, which will now be unrotated. We have SrcRect_u
- With a canvas, draw the selected rectangle of B0_r (srcRect_u) onto B1
However, if B0 is large enough, the rotation operation is very expensive since it applies to the whole bitmap. Also, it means to create an intermediate bitmap each time.
I need to repeat this step in a gameloop, where this rectangle (srcRect) can be rotated and translated, so it must be a "cheap" operation to achieve this
My question: is there a better approach in terms of efficiency , using canvas, matrices and "normal" Views?
EDIT To better illustrate what I mean, I have added some pics.
B0, with the rotated selection zone