Android-Image-Cropper icon indicating copy to clipboard operation
Android-Image-Cropper copied to clipboard

Converting Uri to bitmap

Open minion06 opened this issue 5 years ago • 2 comments

I am trying to convert uri to bitmap using

 val result = CropImage.getActivityResult(data)
            val selectedImage = result.uri
  val source = ImageDecoder.createSource(this.contentResolver, selectedImage)
        val  temp = ImageDecoder.decodeBitmap(source)

and i am getting an exception "java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps" while converting uri to bitmap. And the temp val is empty.

My android os version is O.

minion06 avatar Jan 16 '20 06:01 minion06

I tried this and it worked.

val result = CropImage.getActivityResult(data) val selectedImage = result.uri val options: BitmapFactory.Options = BitmapFactory.Options() options.inJustDecodeBounds = true if (selectedImage.path != null) { //Bitmap val outputBitmap = BitmapFactory.decodeFile(File(selectedImage.path!!).absolutePath, options) }

NouranSamak avatar Mar 01 '20 10:03 NouranSamak

Hey!

I start a new project to handover this library https://github.com/CanHub/Android-Image-Cropper

The ideia is that we keep improving because this project don’t have updates since 2018 Hope I can count with your help.

Open to contribute, next pieces of work will be Android 11 permissions, refactor into Kotlin and ActivityContract

Canato avatar Nov 27 '20 16:11 Canato