I am using ```Image.makeFromEncoded(this).toCompos...
# multiplatform
r
I am using
Copy code
Image.makeFromEncoded(this).toComposeImageBitmap()
Is there a way to get a mutable ImageBitmap instead of immutable one? I try to draw this on a Canvas and always get the error
kotlin.IllegalArgumentException: Cannot draw on immutable ImageBitmap
m
You also create your own custom Image.toBitmap method to create a mutable Bitmap, follow the same Compose internal implementation and remove the line where they are setting the bitmap to be immutable. And then you will have something like this:
Copy code
image.toMutableBitmap().asComposeImageBitmap()
r
Thanks for the answer. this seems to work. I tried to work with
Bitmap
directly, but android Bitmap and skia Bitmap aren’t compatible as type when using in common code (I am relatively new to kotlin multiplatform).
m
Nice, using
asComposeImageBitmap
on the Bitmap should keep it mutable so you can have the compose ImageBitmap that you can use in common. Let me know if you still have any issues.