This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting what is drawn on the screen.  RSS feed

Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a little Android application that allows you to draw a little bit on the screen. I want to be able to save off the image but all I ever get is a blank bitmap.

What I do is

create a bitmap
assign the bitmap to a canvas
assign the bitmap to an image view

If then draw on the thing a little and attempt to save it off by doing

View v = findViewById(;

Bitmap tmpBmp = v.getDrawingCache();

This doesn't seem to work, but what is really odd is that if I load a bitmap into the image just before I do that, it does work just fine. The code I use to do that looks like this:

//This works, so it isn't downstream from's here not saving the right image!
Bitmap tmpBmp = BitmapFactory.decodeResource(getResources(), R.drawable.myapp_icon);
mBitmap = tmpBmp;

It's acting like it just doesn't see the drawing done on the canvas that I do like this:

mCanvas.drawLine(inputDownX, inputDownY, inputUpX, inputUpY, thisPaint);

So any idea what it is that is going on here?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!