• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting what is drawn on the screen.

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic