Tuesday, October 11, 2011

[android-developers] How to control the rotation

Hi,

I have a png file. size is 60X180pixel. I hope to rotate the bitmap
continuously and draw at the same location.

My program is following:

********************************************

matrix.setRotate(gStep*2.0f); //rotation steps
tempbitmap = Bitmap.createBitmap(oldBM, 0, 0, oldBM.getWidth(),
oldBM.getHeight(), matrix, true);
// oldBM is the png file
iwidth = tempbitmap.getWidth();
iheight = tempbitmap.getHeight();
gCenterX = (screenwidth-iwidth)/2.0f; //screenwidth is screen's width
gCenterY = (screenheight-iheight)/2.0f; //screenheight is screen's
height
c.drawBitmap(tempbitmap, gCenterX, gCenterY, paint);

********************************************

When the program running, the bitmap can't be draw in the same
location. That means the gCenterX & gCenterY are always in change.

How to fix it?

Thanks a lot!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment