lyrebirdstudio / Croppy

Image Cropping Library for Android
1.13k stars 83 forks source link

issue with height #15

Open dan085 opened 4 years ago

dan085 commented 4 years ago

this line its the problem


     viewModel
            .getResizedBitmapLiveData()
            .observe(viewLifecycleOwner, Observer { binding.cropView.setBitmap(it.bitmap) })

java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:1113) at android.graphics.Bitmap.createBitmap(Bitmap.java:1080) at android.graphics.Bitmap.createBitmap(Bitmap.java:1030) at android.graphics.Bitmap.createBitmap(Bitmap.java:991) at com.lyrebirdstudio.croppylib.cropview.CropView.createMaskBitmap(CropView.kt:525) at com.lyrebirdstudio.croppylib.cropview.CropView.initialize(CropView.kt:510) at com.lyrebirdstudio.croppylib.cropview.CropView.setBitmap(CropView.kt:404) at com.lyrebirdstudio.croppylib.ui.ImageCropFragment$onActivityCreated$2.onChanged(ImageCropFragment.kt:119) at com.lyrebirdstudio.croppylib.ui.ImageCropFragment$onActivityCreated$2.onChanged(ImageCropFragment.kt:17) at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131) at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149) at androidx.lifecycle.LiveData.setValue(LiveData.java:307) at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50) at com.lyrebirdstudio.croppylib.ui.ImageCropViewModel$setCropRequest$1.accept(ImageCropViewModel.kt:38) at com.lyrebirdstudio.croppylib.ui.ImageCropViewModel$setCropRequest$1.accept(ImageCropViewModel.kt:18) at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62) at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:81) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

dan085 commented 4 years ago

**** I add this line

binding.cropView.post(Runnable { binding.cropView.setBitmap(it.bitmap) })