posted 11 years ago
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(android.R.id.content);
v.setDrawingCacheEnabled(true);
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 here....it's here not saving the right image!
Bitmap tmpBmp = BitmapFactory.decodeResource(getResources(), R.drawable.myapp_icon);
mBitmap = tmpBmp;
mCanvas.setBitmap(tmpBmp);
mImageView.setImageBitmap(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?