ImageCropView icon indicating copy to clipboard operation
ImageCropView copied to clipboard

java.lang.IllegalArgumentException: width and height must be > 0

Open diegoflassa opened this issue 5 months ago • 3 comments

I am having this error

                                                                                                java.lang.IllegalArgumentException: width and height must be > 0
                                                                                                	at android.graphics.Bitmap.createBitmap(Bitmap.java:1102)
                                                                                                	at android.graphics.Bitmap.createBitmap(Bitmap.java:941)
                                                                                                	at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:796)
                                                                                                	at com.image.cropview.CropUtil.cropImage(CropUtil.kt:705)
                                                                                                	at com.image.cropview.ImageCrop.onCrop(ImageCropView.kt:161)
                                                                                                	at br.com.havan.logistica.produtoai.ui.home.TelaHomeKt$TelaHome$2$invoke$$inlined$ConstraintLayout$2.invoke(ConstraintLayout.kt:1572)
                                                                                                	at br.com.havan.logistica.produtoai.ui.home.TelaHomeKt$TelaHome$2$invoke$$inlined$ConstraintLayout$2.invoke(ConstraintLayout.kt:89)
                                                                                                	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
                                                                                                	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                	at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
                                                                                                	at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2823)
                                                                                                	at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3114)
                                                                                                	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3605)
                                                                                                	at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3550)
                                                                                                	at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
                                                                                                	at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1206)
                                                                                                	at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
                                                                                                	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:616)
                                                                                                	at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
                                                                                                	at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
                                                                                                	at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
                                                                                                	at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
                                                                                                	at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
                                                                                                	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1106)
                                                                                                	at android.view.Choreographer.doCallbacks(Choreographer.java:866)
                                                                                                	at android.view.Choreographer.doFrame(Choreographer.java:792)
                                                                                                	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092)
                                                                                                	at android.os.Handler.handleCallback(Handler.java:938)
                                                                                                	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                	at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                	at android.os.Looper.loop(Looper.java:313)
                                                                                                	at android.app.ActivityThread.main(ActivityThread.java:8669)
                                                                                                	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
                                                                                                	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@c0f0b6c, androidx.compose.ui.platform.MotionDurationScaleImpl@96af535, StandaloneCoroutine{Cancelling}@53ebdca, AndroidUiDispatcher@dc68b3b]
                                                                                                	

When calling your lib, like this:

                val imageCrop: ImageCrop = ImageCrop(bitmap.value!!)

                // Configure ImageCropView.
                imageCrop.ImageCropView(
                    modifier = Modifier.fillMaxSize(),
                    guideLineColor = Color.LightGray,
                    guideLineWidth = 2.dp,
                    edgeCircleSize = 5.dp,
                    showGuideLines = true,
                    cropType = CropType.SQUARE,
                    edgeType = EdgeType.CIRCULAR
                )

                val croppedBitmap = imageCrop.onCrop()
                

Yes, bitmap.value is a valid bitmap: bitmap = {ParcelableSnapshotMutableState@33174} Collecting data... mColorSpace = null mDensity = 280 mHardwareBuffer = null mHeight = 3000 mNativePtr = 525779117632 mNinePatchChunk = null mNinePatchInsets = null mRecycled = false mRequestPremultiplied = true mWidth = 4000 shadow$klass = {Class@18085} "class android.graphics.Bitmap" shadow$monitor = -1950744464

diegoflassa avatar Sep 09 '24 15:09 diegoflassa