33

Is it possible to create a bitmap image from a view or the screen in Android?

hpique
  • 116,146
  • 129
  • 332
  • 470

1 Answers1

65

There are a couple of ways to do it. A simple one is to do the following:

Bitmap b = Bitmap.createBitmap(theView.getWidth(), theView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
theView.draw(c);
Romain Guy
  • 96,789
  • 18
  • 217
  • 200
  • 3
    Thanks Romain! Worked like a charm. Glad to see you guys are still around answering questions. – hpique Jun 22 '10 at 17:48