naver / android-imagecropview

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

getCroppedImage() ClassCastException #28

Closed MohNage7 closed 5 years ago

MohNage7 commented 6 years ago

Hello first of all thanks for the library . i'm having this issue when i'm trying to use the code below

Bitmap bitmap = mCropView.getCroppedImage();

java.lang.ClassCastException: com.bumptech.glide.request.target.SquaringDrawable cannot be cast to com.naver.android.helloyako.imagecrop.view.graphics.FastBitmapDrawable at com.naver.android.helloyako.imagecrop.view.ImageCropView.getViewBitmap(ImageCropView.java:951) at com.naver.android.helloyako.imagecrop.view.ImageCropView.getCropInfo(ImageCropView.java:938) at com.naver.android.helloyako.imagecrop.view.ImageCropView.getCroppedImage(ImageCropView.java:921)

helloyako commented 6 years ago

Hello.

I don't know your status.

can you give me more information?

sriharshaarangi commented 6 years ago

I am having the same issue

sriharshaarangi commented 6 years ago

Solved by using imageCropView.setImageFilePath(path); instead of imageCropView.setImageURI(imageUri);

Altair1908 commented 2 years ago

This is not actually a solution. We have setImageURI() method and it doesn't work correctly with imageCropView.

AndroidCrypto commented 2 years ago

@Altair1908: I encountered the same problem and I found a (dirty & hack) solution.

Before importing the Uri with setImageURI(imageUri) I placed these lines:

ImageView imageView = findViewById(R.id.ivInvisible);
imageView.setImageURI(result);
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap = drawable.getBitmap();
imageCropView.setImageBitmap(bitmap); 

To get this to work I needed to place an "invisible" regular ImageView in the XML-file:

<ImageView
        android:id="@+id/ivInvisible"
        android:layout_width="0dp"
        android:layout_height="0dp"/>

Greetings Michael