The example in this article describes how the Android implementation saves view to bitmap. Share to everyone for your reference, specific as follows:
1,
Public Bitmap Convertviewtobitmap (view view) {
Bitmap Bitmap = Bitmap.createbitmap (View.getwidth (), View.getheight (),
Bitmap.Config.ARGB_8888);
Using bitmap to generate canvas
Canvas Canvas = new Canvas (bitmap);
Draw the contents of the view on the canvas
view.draw (canvas);
return bitmap;
}
2,
/** * Save View as a bitmap/private bitmap Saveviewbitmap (view view) {//Get current
View Bitmap view.setdrawingcacheenabled (true);
View.builddrawingcache (TRUE);
Bitmap Bitmap = View.getdrawingcache (true);
Bitmap bmp = Duplicatebitmap (BITMAP);
if (bitmap!= null &&!bitmap.isrecycled ()) {bitmap.recycle (); bitmap = null;}
Clear the cache view.setdrawingcacheenabled (false);
return BMP;
public static Bitmap Duplicatebitmap (Bitmap bmpsrc) {if (null = = BMPSRC) {return null;}
int bmpsrcwidth = Bmpsrc.getwidth ();
int bmpsrcheight = Bmpsrc.getheight (); Bitmap bmpdest = Bitmap.createbitmap (Bmpsrcwidth, Bmpsrcheight, config.argb_8888);
if (null!= bmpdest) {Canvas Canvas = new Canvas (bmpdest); final Rect Rect = new Rect (0, 0, bmpsrcwidth, bmpsrcheight); Canvas.drawbitmap (BMPSRC, rect, rect, null);
return bmpdest; }
For more information on Android-related content readers can view the site topics: "Android File Operation tips Summary", "Android programming development of the SD card operation Summary", "Android Development introduction and Advanced Course", "Android Resources Operating Skills summary", " Android View tips Summary and a summary of the use of Android controls
I hope this article will help you with the Android program.