Created
March 29, 2019 17:58
-
-
Save traendy/f74d8de6941e896b90e8d74a0af1ce65 to your computer and use it in GitHub Desktop.
Method to read bitmap from an uri.
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
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