Created
November 10, 2016 08:42
-
-
Save iammert/5ccf8b8cf799d961602e4b93d3cf7640 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 static File bitmapToFile(Context context, Bitmap bitmap, String fileName) throws IOException { | |
File f = new File(context.getCacheDir(), fileName); | |
f.createNewFile(); | |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
bitmap.compress(Bitmap.CompressFormat.JPEG, 50 , bos); | |
byte[] bitmapdata = bos.toByteArray(); | |
FileOutputStream fos = new FileOutputStream(f); | |
fos.write(bitmapdata); | |
fos.flush(); | |
fos.close(); | |
return f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment