Edit (shrink, doodle, etc.) the picture and save it to a picture of the specified format and size.
Post Code First:
Copy Code code as follows:
Bitmap bmp = Bitmap.createbitmap (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 (Bitmap.CompressFormat.PNG, FOS);
Fos.close ();
System.out.println ("Savebmp is Here");
catch (Exception e) {
E.printstacktrace ();
}
explain:
1, first create a bitmap picture, and specify the size;
2, create a new canvas canvas on the picture, then draw on the canvas, and save it;
3, need to save the directory file, note If you write the directory such as "/sdcard/akai/" if it does not exist, first create (File.mkdirs ()), or FileOutputStream will be the error no found;
4, need to add permissions: <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>