canvas saves the bitmap to the local

File f = new File("/sdcard/DCIM/Camera/0.png");
                       FileOutputStream fos = null;
                       try {
                           fos = new FileOutputStream(f);
                           drawBitmap.compress(Bitmap.CompressFormat.PNG, 50, fos);
                       } catch (FileNotFoundException e) {
                           // TODO Auto-generated catch block
                           e.printStackTrace ();
                       }

 

<!-- Create and delete file permissions in SDCard-->     
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>     
<!-- Write data permission to SDCard-->     
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

Reference: http://wuxiaolong.me/2015/04/23/CanvasToPhoto/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325010923&siteId=291194637