Skip to content

Instantly share code, notes, and snippets.

@chiragthummar
Created September 6, 2023 14:06
Show Gist options
  • Save chiragthummar/7377f135627511308cb18c231fd85b05 to your computer and use it in GitHub Desktop.
Save chiragthummar/7377f135627511308cb18c231fd85b05 to your computer and use it in GitHub Desktop.
val picture = remember { Picture() }
Column(
modifier = Modifier
.padding(padding)
.fillMaxSize()
.drawWithCache {
// Example that shows how to redirect rendering to an Android Picture and then
// draw the picture into the original destination
val width = this.size.width.toInt()
val height = this.size.height.toInt()
onDrawWithContent {
val pictureCanvas =
androidx.compose.ui.graphics.Canvas(
picture.beginRecording(
width,
height
)
)
draw(this, this.layoutDirection, pictureCanvas, this.size) {
this@onDrawWithContent.drawContent()
}
picture.endRecording()
drawIntoCanvas { canvas -> canvas.nativeCanvas.drawPicture(picture) }
}
}
) {
ScreenContentToCapture()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment