What is the most optimal way to write a load of pixels to Canvas or Image? I use drawPixels now, but I have a lot of different colors so that results in a lot of different drawPixels calls. In a non Compose world I'd just fill a bitmap and render that but I have trouble finding this. I see the ImageBitmap and Painter interfaces, but I haven't found a way to use them correctly.
r
Radoslaw Juszczyk
09/12/2022, 7:15 AM
this should help:
Copy code
val info = ImageInfo.makeN32(1920, 1080, ColorAlphaType.OPAQUE)
val bmp = org.jetbrains.skia.Bitmap()
bmp.allocPixels(info)
bmp.installPixels(byteArray)
imageBitmap = bmp.asComposeImageBitmap()
Okay, so I couldn't figure out why this is not working, but it only works in Desktop-code. Not in common code. Is there a way to do this in common code? Otherwise it doesn't make a lot of sense for me.