Howdy Android Gurus!

I am hoping someone out there who is an expert in GFX (or at least not
a n00b like me), can give me some words of wisdom.  In my onDraw
callback I am presently displaying a simple bitmap, its just 48x48
pixels.  I load it up early on like this:

// during initialization i load the origial BitMap (48 x 48) and a
paint brush
Bitmap mBitmap =
BitmapFactory.decodeResource(getResources(),R.drawable.my_image);
Paint p = new Paint();

then in my onDraw I splat it to the canvas:

// c is my canvas object
// in my main onDraw loop i display my bitmap
c.drawBitmap(mBitmap,0,0,p);

So far so good.  Later though, I wish to rotate the image.  I try to
create a new image based upon the original and draw it using the
canvas object:

// mRotation = some value between 15 and 345
Matrix m = new Matrix();
m.setRotate(mRotation, (float)(mBitmap.getWidth()/2), (float)
(mBitmap.getHeight()/2));
Bitmap b = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(),
mBitmap.getHeight(), m, true);
c.drawBitmap(b,0,0,p);

The issue is the image quality seems to degrade greatly in the rotated
images, and its really tough to get the image to rotate in place
despite the image being square and me specifying the center as the
pivot point.  I am sure this is just me not knowing what I am doing
but any help anyone could offer would be appreciated.

I did go through several tutorials online but they all seem to end up
putting the image in a stationary imageview / layout and are not using
the canvas to draw the resulting bitmap.  The image itself is nothing
fancy, and only a couple colors.  Maybe this is not the right approach
at all?  I realize its not the most efficient approach but my
application is not exactly giving the CPU a work out and drawing the
bitmap using the canvas inside the onDraw works well with the rest of
my application architecture.

Thanks in advance to anyone who has some advice for me.

Regards!

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

Reply via email to