Edit (scale down, graffiti, etc.) the image and save it as an image of the specified format and size.
Post firstCode :
Copy code The Code is as follows: bitmap BMP = bitmap. createbitmap (480,800, config. argb_8888 );
Canvas canvas = new canvas (BMP );
Canvas.drawbitmap(this.bmp, matrix, paint );
Canvas. Save (canvas. all_save_flag );
Canvas. Restore ();
File file = new file ("/sdcard/Akai /");
If (! File. exists ())
File. mkdirs ();
Try {
Fileoutputstream Fos = new fileoutputstream (file. getpath () + "/2.png ");
BMP. Compress (fig. compressformat. PNG, 100, FOS );
FOS. Close ();
System. Out. println ("savebmp is here ");
} Catch (exception e ){
E. printstacktrace ();
}
Explanation:
1. Create a bitmap image and specify the size;
2. Create a new canvas on the image, draw it on the canvas, and save it;
3. directory file to be saved. Note that if the written directory is "/sdcard/Akai/", you must first create a file. mkdirs (); otherwise, no found is returned for fileoutputstream;
4. Add permissions: <uses-Permission Android: Name = "android. Permission. write_external_storage"/>