https://kotlinlang.org logo
#compose
Title
# compose
e

eygraber

03/08/2021, 11:11 PM
Is there a built in way to create an ImageBitmap from an array of rgba values?
t

Timo Drick

03/09/2021, 12:08 AM
You can use the normal android Bitmaps which support that. Nothing special in Compose here.
Copy code
Bitmap.createBitmap(rgbaArray, width, height, config).asImageBitmap()
e

eygraber

03/09/2021, 12:14 AM
I'm using the multiplatform version of Compose, and trying to recreate this - https://medium.com/@bantic/hand-coding-a-color-wheel-with-canvas-78256c9d7d43
t

Timo Drick

03/09/2021, 12:31 AM
Unfortunatley in Compose for Desktop you have to use the Skia library for bitmap handling.
There is Image.makeFromEncoded(bytes) but this expects an compressed image format.
You could use BufferedImage from Swing but i think this is not so good performance like skia.
@eygraber You know that you can also draw canvas in Compose?
e

eygraber

03/09/2021, 4:26 AM
Yup, I solved it using drawOval for each Pixel. Thanks 😅
2 Views