I need to create an ImageBitmap from raw ARGB pixe...
# compose-desktop
m
I need to create an ImageBitmap from raw ARGB pixels contained in an IntArray. On Android I do this like this
Copy code
override fun imageBitmapFromArgb(rawArgbImageData: IntArray, width: Int, height: Int): ImageBitmap {
    val image = ImageBitmap(width, height, ImageBitmapConfig.Argb8888, true, ColorSpaces.Srgb)
    image.asAndroidBitmap().setPixels(rawArgbImageData, 0, width, 0, 0, width, height)
    return image
}
but there does not seem to be a suitable way to do the same on desktop. The Skia bitmap does not seem to have a
setPixels
method.
o
Why not use
Copy code
Bitmap.makeFromImage(Image.makeFromEncoded(bytes))
?
m
@olonho Because “encoded” bytes are not the same as “raw” bytes. Encoded bytes refer to the bytes of, e.g., a JPEG file but I have unencoded raw bytes after I did some image processing.
o
There are similar API for raw pixels in Image