Michael Paus
08/25/2021, 2:51 PMoverride fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
val bitmap = BitmapFactory.decodeByteArray(encodedImageData, 0, encodedImageData.size)
return bitmap.asImageBitmap()
}
and on Desktop I use
override fun imageBitmapFromBytes(encodedImageData: ByteArray): ImageBitmap {
return Image.makeFromEncoded(encodedImageData).asImageBitmap()
}
but I think something like this actually belongs into Compose itself.
One also might add a similar method to construct an ImageBitmap from a raw bitmap represented as a byte array plus some image info needed to reconstruct the image.
What do you think?romainguy
08/25/2021, 4:00 PMImageBitmap
from a byte array would make sense but we would need to know the layout of said byte array (ARGB vs RGBA vs BGRA vs ABGR for instance, and that’s only for 8-bit encodings), which you would obtain from the platform’s native bitmap object anywayjim
08/25/2021, 4:08 PMMichael Paus
08/25/2021, 4:11 PMjim
08/25/2021, 4:19 PMMichael Paus
08/25/2021, 4:28 PMromainguy
08/25/2021, 4:39 PMimageBitmapFromBytes
as a platform-specific implementation that just delegates to platform-specific decoders + extension methods would make sense.jim
08/25/2021, 4:47 PMMichael Paus
08/25/2021, 4:51 PMjim
08/25/2021, 4:52 PMMichael Paus
08/25/2021, 4:54 PM