Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create image from view/screen in Android

Tags:

android

bitmap

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

like image 681
hpique Avatar asked Jun 22 '10 16:06

hpique


People also ask

What is ImageView in Android?

Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling.

How do I take a picture of my Android Gallery?

Run the application on an Android phone. Selecting "Take photo" will open your camera. Finally, the image clicked will be displayed in the ImageView. Selecting "Choose from Gallery" will open your gallery (note that the image captured earlier has been added to the phone gallery).

What is a bitmap Android?

A bitmap (or raster graphic) is a digital image composed of a matrix of dots. When viewed at 100%, each dot corresponds to an individual pixel on a display. In a standard bitmap image, each dot can be assigned a different color. In this instance we will simply create a Bitmap directly: Bitmap b = Bitmap.


1 Answers

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); 
like image 98
Romain Guy Avatar answered Nov 01 '22 11:11

Romain Guy