How to draw image in canvas compose without stretching the image

43 Views Asked by At

I am using canvas composable to draw an image bitmap and get the result like this

enter image description here

This is my code to draw the image and the image source is a landscape image

Canvas(modifier = Modifier.fillMaxSize(), onDraw = {
        drawImage(imageBitmap, dstSize = IntSize(size.width.toInt(), size.height.toInt()),)
    })

Is there any way to keep the image not stretching while drawing it in canvas? Really appreciate any suggestions

--- Update ---

This is the result I expect

enter image description here

0

There are 0 best solutions below