naver / android-imagecropview

android image crop library
Apache License 2.0
254 stars 55 forks source link

val bitmap:Bitmap = CroppedImage (Kotlin) #34

Closed salmanhameed2018 closed 5 years ago

salmanhameed2018 commented 5 years ago

Hello, I'm using your library for my latest project, the source of my images is from the camera and SD card, when I use images for cropping from camera it works well, but crashes when my source is an SD card, please help me out,

NOTE: I HAVE APPLY THIS SOLUTION (https://github.com/naver/android-imagecropview/issues/28)

here is the crash.

java.lang.ClassCastException: android.graphics.drawable.BitmapDrawable cannot be cast to com.naver.android.helloyako.imagecrop.view.graphics.FastBitmapDrawable

helloyako commented 5 years ago

Hello.

Did you compare paths from camera and SD card? Path is parameter in imageCropView.setImageFilePath(path);

Can you tell me paths both?

salmanhameed2018 commented 5 years ago

yes sure,

for camera: /storage/emulated/0/Android/data/photoblender.kotlin.thetamobile.com.photoblender/files/Pictures/JPEG_20190107_141900_1962870013120570186.jpg

for gallery: content://media/external/images/media/3758

helloyako commented 5 years ago

You have to convert content uri to file path.

ref. https://stackoverflow.com/questions/3401579/get-filename-and-path-from-uri-from-mediastore

ps. I think it's better to convert convert uri to file path in this library. However, I don't know When I can update that feature.

salmanhameed2018 commented 5 years ago

thanks, below solution works for me,

var bitmapPath:String = intent.getStringExtra(SELECTED_IMAGE_PATH) val bitmap = MediaStore.Images.Media.getBitmap(this.contentResolver, Uri.parse(bitmapPath)) iv_selected_crop_image.setImageBitmap(bitmap)

helloyako commented 5 years ago

I am glad problem is solved