canvas 保存bitmap到本地
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();
}
<!-- 在SDCard中创建与删除文件权限 --> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <!-- 往SDCard写入数据权限 --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
参考:http://wuxiaolong.me/2015/04/23/CanvasToPhoto/