I'm using a @Composable
where I need to pass via parameter an ImageBitmap
, the problem is that I get the images from the server given an url so I need to load these images, convert them into a Bitmap
and then to a ImageBitmap
but I'm quite stuck because I don't know how to convert this to an ImageBitmap
, this is my @Composable
@ExperimentalComposeUiApi
@Composable
fun MyCanvas(
myImage: ImageBitmap,
modifier: Modifier = Modifier,
) {
Canvas(modifier = modifier
.size(220.dp)
.clipToBounds()
.clip(RoundedCornerShape(size = 16.dp)) {
...
val canvasWidth = size.width.toInt()
val canvasHeight = size.height.toInt()
val imageSize = IntSize(width = canvasWidth, height = canvasHeight)
drawImage(
image = myImage, dstSize = imageSize
)
...
}
}
So, when I call this @Composable
I need to load the image but not sure how to start with and I need to know what's better either using Glide or Coil.