//保存bitmap到指定文件。
public static void saveBitmap(Bitmap bmp, String targetPath) {
File file = new File(targetPath);if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try {
saveBitmap(bmp, new FileOutputStream(file));
} catch (Exception e) {
e.printStackTrace();
}
}
private static void saveBitmap(Bitmap bmp, FileOutputStream fos) {
try {
//80 is the compress quality
bmp.compress(Bitmap.CompressFormat.JPEG, 80, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.flush();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}