I have a function that returns a bitmap (which "contains" a QR code) and I wanted to display that bitmap inside an Image
(composable function) but I didn't find any way to either convert the bitmap into a ImageBitmap
or just displaying that bitmap.
Based on this blog post, it should be possible to display a bitmap like this :
@Composable
fun BitmapImage(bitmap: Bitmap) {
Image(
bitmap = bitmap.asImageBitmap(),
contentDescription = "some useful description",
)
}
I haven't tried it out myself, but recently came across the blog post when looking into displaying maps using Jetpack Compose.
Coil is capable of displaying a Bitmap
inside Image
:
Image(
painter = rememberAsyncImagePainter(imageBitmap),
contentDescription = null,
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With