Convert an image into a bitmap object and draw it through a canvas layer by layer. Of course, a bitmap object can be used for image rotation, image scaling, and other functions.
Private bitmap drawpicture (Bitmap mbitmap)
{
Bitmap bitmap = mbitmap;
// Bitmapfactory. decoderesource (getresources (), R. drawable. mymoive_01 );
Bitmap mbitmap = bitmap. createbitmap (bitmap. getwidth () + 4, bitmap. getheight () + 4, bitmap. config. argb_8888 );
Canvas mcanvas = new canvas (mbitmap );
Paint mpaint = new paint ();
Mpaint. setcolor (color. White );
Mcanvas. drawrect (0, 0, bitmap. getwidth () + 4, bitmap. getheight () + 4, mpaint );
Mcanvas. drawbitmap (bitmap, 2, 2, new paint ());
Mcanvas. Save (canvas. all_save_flag );
Mcanvas. Restore ();
Matrix matrix = new matrix ();
Matrix. setrotate (8 );
Bitmap newbitmap = bitmap. createbitmap (mbitmap, 0, 0, mbitmap. getwidth (), mbitmap. getheight (), matrix, true );
Matrix. setrotate (5 );
Bitmap xbitmap = bitmap. createbitmap (mbitmap, 0, 0, mbitmap. getwidth (), mbitmap. getheight (), matrix, true );
Canvas canvas = new canvas (newbitmap );
Canvas. drawbitmap (xbitmap, 0, 0, new paint ());
Canvas. drawbitmap (mbitmap, 0, 4, new paint ());
Canvas. drawbitmap (mbitmap, 0, 10, new paint ());
Canvas. Save (canvas. all_save_flag );
Canvas. Restore ();
String filename = "/sdcard/12.png ";
File file = new file (filename );
Fileoutputstream out;
Try {
File. createnewfile ();
Out = new fileoutputstream (File );
Newbitmap. Compress (bitmap. compressformat. PNG, 100, out );
Log. E ("system. Out", "Save OK ");
} Catch (filenotfoundexception e ){
// Todo auto-generated Catch Block
Log. E ("system. Out", E. tostring ());
E. printstacktrace ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
Log. E ("system. Out", E. tostring ());
E. printstacktrace ();
}
Return newbitmap;
}