Javokhir Savriev
01/24/2024, 8:55 PMBehzod
01/25/2024, 5:00 AMCanvas(imgBitmap)
.
On the other hand, if you want to convert a Painter
drawn on a Canvas
to an ImageBitmap
, you can write it as follows:
fun Painter.toImageBitmap(width: Int, height: Int): ImageBitmap {
val imgBitmap = ImageBitmap(width, height)
Canvas(imgBitmap).apply {
CanvasDrawScope().draw(
density = Density(1f, 1f),
layoutDirection = LayoutDirection.Ltr,
canvas = imgBitmap,
size = Size(width.toFloat(), height.toFloat())
)
}
return imgBitmap
}
For saving, you can check the implementation of Coil or Kamel libraries.Javokhir Savriev
01/26/2024, 4:24 PMdrawLine
. Now, I’m looking for a way to capture and save the content of this Canvas. Any tips or examples on how to efficiently capture the drawn lines and possibly save them as an image? Your insights would be really helpful!
Thanks!Javokhir Savriev
01/26/2024, 4:25 PMJavokhir Savriev
01/26/2024, 4:25 PMMuhammad hosein Merati
03/05/2024, 11:24 AMJavokhir Savriev
03/05/2024, 11:36 AMMuhammad hosein Merati
03/05/2024, 11:38 AM