Created
August 2, 2017 07:17
-
-
Save dron247/9f2dfe44a3bec7cfaff0c26ca4d5b3aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private File saveBitmap(Bitmap bmp, String fileName) { | |
if (bmp == null) return null; | |
String extStorageDirectory = Environment.getExternalStorageDirectory() | |
.toString(); | |
OutputStream outStream = null; | |
File file = new File(extStorageDirectory, fileName + ".png"); | |
if (file.exists()) { | |
file.delete(); | |
file = new File(extStorageDirectory, fileName + ".png"); | |
log("file exist " + file + ",Bitmap= " + bmp); | |
} | |
try { | |
outStream = new FileOutputStream(file); | |
bmp.compress(Bitmap.CompressFormat.PNG, 100, outStream); | |
outStream.flush(); | |
outStream.close(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
log("error save " + e.getMessage()); | |
} | |
log("file = " + file); | |
return file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment