Skip to content

Instantly share code, notes, and snippets.

@traendy
Created March 29, 2019 17:58
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 traendy/f74d8de6941e896b90e8d74a0af1ce65 to your computer and use it in GitHub Desktop.
Save traendy/f74d8de6941e896b90e8d74a0af1ce65 to your computer and use it in GitHub Desktop.
Method to read bitmap from an uri.
fun handleSamplingAndRotationBitmap(context: Context, selectedImage: Uri): Bitmap? {
val imageStream = context.contentResolver.openInputStream(selectedImage)
val image = BitmapFactory.decodeStream(imageStream, null, BitmapFactory.Options())
imageStream?.close()
return if(image != null){
rotateImageIfRequired(image, selectedImage)
} else {
image
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment