【发布时间】:2021-10-23 14:39:03
【问题描述】:
我有一个返回位图(“包含”二维码)的函数,我想在Image(可组合函数)中显示该位图,但我没有找到任何方法将位图转换为ImageBitmap 或仅显示该位图。
【问题讨论】:
标签: android-jetpack-compose android-bitmap android-image
我有一个返回位图(“包含”二维码)的函数,我想在Image(可组合函数)中显示该位图,但我没有找到任何方法将位图转换为ImageBitmap 或仅显示该位图。
【问题讨论】:
标签: android-jetpack-compose android-bitmap android-image
基于this blog post,应该可以显示这样的位图:
@Composable
fun BitmapImage(bitmap: Bitmap) {
Image(
bitmap = bitmap.asImageBitmap(),
contentDescription = "some useful description",
)
}
我自己没有尝试过,但最近在研究使用 Jetpack Compose 显示地图时偶然发现了这篇博文。
【讨论】:
Coil 能够在Image 内显示Bitmap:
Image(
painter = rememberImagePainter(imageBitmap),
contentDescription = null,
)
【讨论】: