I have a drawing app I'd like to have the ability to:

1) in onDraw, display a 'thumbnail' view of the current screen to to
user (thumbnail will be in bottom corner, so the user can see where
they are if they zoom in)

2) save the Screen to the SD card as an image file.

So I am trying to figure out how to set up my View properly such that
I can access the Bitmap that the onDraw is drawing too as I need it
from anywhere (I will need to save the Bitmap when the calling
Activity is being shutdown, etc).

I have two fields in my custom View class, mCanvas, mBitmap.  In
onSizeChanged(), when the View is expanded, I instatiate the objects
like so:

mCanvas = new Canvas();
mBitmap = Bitmap.createBitmap(getWidth(), getHeight(),
Bitmap.Config.ARGB_8888);
mCanvas.setBitmap(mBitmap);
draw(mCanvas);

My understanding is that calling draw(mCanvas) sets the canvas to use
in subsequent onDraw() calls so that all drawing in onDraw will be
sent via mCanvas to mBitmap.  Is this correct?

I ask because I have been trying to tackle #1 above, and when I get a
scaled version of the bitmap in onDraw when I try to draw the
thumbnail, the scaled version is not showing the elements that are
being added to the canvas.  For instance, if I draw lines to the
canvas, via onDraw, I see those on the screen.  If I draw more lines,
those show up.  If I then zoom in and at the time of zooming, scale
the bitmap, it is blank.  Here is how I am scaling the bitmap,
thumbnailRectF is a rectangle that I draw to the screen prior to this
call, using it as a border for the thumbnail:

Bitmap out = Bitmap.createScaledBitmap(mBitmap, 100, 100, false);
canvas.drawBitmap(out, null, thumbnailRectF, thumbCanvasPaint);

Am I doing something obviously incorrect in how I am attaching the
View's built-in canvas to my mBitmap?  Can anyone suggest a better way
to do this?

Thanks,

Paul

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to