Skip to content

Capture Area

In this example I use a graphicsLayer to store the draw action in drawWithContent scope

val graphicsLayer = rememberGraphicsLayer()
Box(
modifier = Modifier
.fillMaxSize()
.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
}
drawLayer(graphicsLayer)
}
) { }

finally we can extract the bitmap from graphicsLayer

graphicsLayer.toImageBitmap().asAndroidBitmap()