public void saveBitmap(Bitmap bm, String path) {
String dir = path.substring(0,path.lastIndexOf("/"));
File dirFile = new File(dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
File f = new File(path);
if (f.exists()) {
f.delete();
}
FileOutputStream out = null;
try {
out = new FileOutputStream(f);
bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
将bitmap保存为文件
最新推荐文章于 2021-02-19 00:34:08 发布