compose-capture-to-share-image
Installation
SKILL.md
Capturing a composable to a shareable image
Three pieces, each an expect/actual pair except the capture itself:
- A
capturable()modifier plusCaptureController— common code, no platform split — that records a composable's own draw pass into aGraphicsLayerand hands it back as anImageBitmapon demand. ImageBitmap.toPngByteArray()— PNG, not whatever format the app's existing bitmap-to-bytes function already produces.saveImageToDevice()/shareImage()— MediaStore plus a share sheet on Android, a downloads write plus "reveal in the file manager" on Desktop.
fun Modifier.capturable(controller: CaptureController): Modifier = this then CapturableModifierNodeElement(controller)