Yan Pujante
05/16/2022, 5:41 PM@Composable
fun Panel(image: ImageBitmap) {
Canvas(modifier = Modifier
.size(image.width.dp, image.height.dp) // doesn't work (mismatch size)
.border(1.dp, Color.Red)) {
drawIntoCanvas { canvas ->
canvas.withSave {
canvas.drawImage(image, Offset(0f, 0f), Paint())
}
}
}
}
Kirill Grouchnikov
05/16/2022, 6:02 PMYan Pujante
05/16/2022, 6:03 PMKirill Grouchnikov
05/16/2022, 6:03 PMLocalDensity
to convert between the twoZach Klippenstein (he/him) [MOD]
05/16/2022, 6:20 PMtoDp()
not dp
Zach Klippenstein (he/him) [MOD]
05/16/2022, 6:21 PMdp
means “this value is a dp”, toDp()
means “this value is a pixel and I want to convert it to a dp in the current density”Yan Pujante
05/16/2022, 6:22 PMval canvasWidth = with(LocalDensity.current) { image.width.toDp() }
Thank youYan Pujante
05/16/2022, 6:23 PMtoDP()
does not work on its ownKirill Grouchnikov
05/16/2022, 6:26 PMZach Klippenstein (he/him) [MOD]
05/16/2022, 6:26 PMDensity
in the receiverYan Pujante
05/16/2022, 6:35 PM