Created
October 22, 2019 02:28
-
-
Save cdmunoz/fe93be9572d7994fbc3d04c2717f7291 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun savePickedImage(activity: Activity) { | |
val bm = BitmapFactory.decodeResource(activity.resources, R.mipmap.ic_launcher) | |
val dir = activity.externalCacheDir | |
val file = File(dir?.path, "pickImageResult.jpeg") | |
val outStream: FileOutputStream? | |
try { | |
outStream = FileOutputStream(file) | |
bm.compress(Bitmap.CompressFormat.JPEG, 100, outStream) | |
with(outStream) { | |
flush() | |
close() | |
} | |
} catch (e: FileNotFoundException) { | |
e.printStackTrace() | |
} catch (e: IOException) { | |
e.printStackTrace() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment