Created
November 9, 2016 17:49
-
-
Save iamcxa/d7dbbdde71e81b4de4a2b3b15b324008 to your computer and use it in GitHub Desktop.
How to store a bitmap into file
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 void storeImage(Bitmap image) { | |
File pictureFile = getOutputMediaFile(); | |
if (pictureFile == null) { | |
Log.d(TAG, | |
"Error creating media file, check storage permissions: ");// e.getMessage()); | |
return; | |
} | |
try { | |
FileOutputStream fos = new FileOutputStream(pictureFile); | |
image.compress(Bitmap.CompressFormat.PNG, 90, fos); | |
fos.close(); | |
} catch (FileNotFoundException e) { | |
Log.d(TAG, "File not found: " + e.getMessage()); | |
} catch (IOException e) { | |
Log.d(TAG, "Error accessing file: " + e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment