34

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

hpique
  • 119,096
  • 131
  • 338
  • 476

1 Answers1

69

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
  • 97,993
  • 18
  • 219
  • 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