Skip to content

Instantly share code, notes, and snippets.

@mdavalos1993
Created June 10, 2020 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdavalos1993/603fda13221bbcdc152d90b8d63758a9 to your computer and use it in GitHub Desktop.
Save mdavalos1993/603fda13221bbcdc152d90b8d63758a9 to your computer and use it in GitHub Desktop.
private fun storeImage(bitmap: Bitmap, fileName: String){
val wrapper = ContextWrapper(context)
var file = wrapper.getDir("images", Context.MODE_PRIVATE)
file = File(file, "${fileName}.jpg")
try{
val stream: OutputStream = FileOutputStream(file)
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream)
stream.flush()
stream.close()
imageUri = Uri.parse(file.absolutePath)
}
catch (e: IOException){
e.printStackTrace()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment