views:

157

answers:

0

Hi, I'm trying to rotate a bitmap (which is bigger than Canvas) keeping it centered with Canvas and repeatedly in time, in order to make it appears as spinning. I wanted to post an image explaining the situation, but I can't (not enough reputations; it's a pitty because I've spent a lot of time doing it :( ). I hope you understand what's the problem, anyway.

Since I don't want the rest of drawables drawn to the Canvas to be rotated as well, I can't use Canvas.rotate(). So I've tried all the different combinations using matrix, and drawing the bitmap to the Canvas using an offset, for example:

Matrix matrix = new Matrix();
matrix.postRotate(degree); //degree is increasing with time
mrotatedbackground = CreateBitmap(mbackground, (mbackground.getWidth()-screenwidth)/2, (mbackground.screenHeight()-screenheight)/2, screenwidth, screenheight, matrix, true); 
canvas.drawBitmap(mrotatedbackground, -screenwidth/2, -screenheight/2, paint); 

And after lots of hours and many different unsuccessful attempts I'm quite desperate... Can anyone help me, please ? What am I doing wrong ?

Thank you in advance !!