CanHub / Android-Image-Cropper

Image Cropping Library for Android, optimised for Camera / Gallery.

Home Page:https://canhub.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crashing on calling the copping activity...

ErDeepChand opened this issue · comments

Code to call the cropping library

private fun getCroppedImage() {
        cropImage.launch(
            CropImageContractOptions(
                uri = null,
                CropImageOptions(
                    imageSourceIncludeGallery = true,
                    imageSourceIncludeCamera = true,
                    guidelines = CropImageView.Guidelines.ON,
                    outputCompressFormat = Bitmap.CompressFormat.PNG
                )
            )
        )
    }

Calling Intent:

private val cropImage = registerForActivityResult(CropImageContract()) { result ->
        if (result.isSuccessful) {
            // use the returned uri
            val uriContent = result.uriContent
            croppedImageBitmap =
                appUtils.getBitmapFromUri(this@PodDeliveryActivity, result.uriContent)
            base64ImageString = appUtils.convertBitMapToBase64(croppedImageBitmap)
            //appUtils.setImageWithGlide(this, uriContent, binding.ivAsmoreinfoPicture)

        } else {
            val exception = result.error
            Log.e(TAG, "Copping Exception: ${exception?.localizedMessage}")
        }
    }

2024-02-02 00:42:47.525 AndroidRuntime FATAL EXCEPTION: main
Screenshot 2024-02-02 at 12 49 26 AM

                                            java.lang.RuntimeException: Could not copy bitmap to parcel blob.
                                            	at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
                                            	at android.graphics.Bitmap.writeToParcel(Bitmap.java:2124)
                                            	at android.os.Parcel.writeParcelable(Parcel.java:1952)
                                            	at android.os.Parcel.writeValue(Parcel.java:1858)
                                            	at android.os.Parcel.writeArrayMapInternal(Parcel.java:1023)
                                            	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
                                            	at android.os.Bundle.writeToParcel(Bundle.java:1304)
                                            	at android.os.Parcel.writeBundle(Parcel.java:1092)
                                            	at android.os.Parcel.writeValue(Parcel.java:1849)
                                            	at android.os.Parcel.writeSparseArray(Parcel.java:1180)
                                            	at android.os.Parcel.writeValue(Parcel.java:1883)
                                            	at android.os.Parcel.writeArrayMapInternal(Parcel.java:1023)
                                            	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
                                            	at android.os.Bundle.writeToParcel(Bundle.java:1304)
                                            	at android.os.Parcel.writeBundle(Parcel.java:1092)
                                            	at android.os.Parcel.writeValue(Parcel.java:1849)
                                            	at android.os.Parcel.writeArrayMapInternal(Parcel.java:1023)
                                            	at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1620)
                                            	at android.os.Bundle.writeToParcel(Bundle.java:1304)
                                            	at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1278)
                                            	at android.app.ActivityClient.activityStopped(ActivityClient.java:83)
                                            	at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143)
                                            	at android.os.Handler.handleCallback(Handler.java:938)
                                            	at android.os.Handler.dispatchMessage(Handler.java:99)
                                            	at android.os.Looper.loopOnce(Looper.java:201)
                                            	at android.os.Looper.loop(Looper.java:288)
                                            	at android.app.ActivityThread.main(ActivityThread.java:7842)
                                            	at java.lang.reflect.Method.invoke(Native Method)
                                            	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                                            	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)