Hey,
@Javokhir Savriev
If I understand correctly, you can achieve this simply by using
Canvas(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.