CaptureController

Capture a composable subtree as an ImageBitmap, on every Compose Multiplatform target.

This is Compose's own graphics-layer API (rememberGraphicsLayer / GraphicsLayer.record / GraphicsLayer.toImageBitmap) wrapped in the two things a caller actually wants: a handle to trigger the capture from outside the draw phase, and a modifier to mark what gets captured.

Deliberately NOT a dependency on dev.shreyaspatil:capturable. That library is built on this same API and handles the same cases, but it is Android-only, and this toolkit ships to Android, iOS, desktop and wasm from one source set. Fifteen lines here beat an Android-only artifact.

val controller = rememberCaptureController()
Card(Modifier.capturable(controller)) { ReferralSummary(state) }
Button(onClick = { scope.launch { onShare(controller.captureAsImageBitmap()) } }) { ... }

Functions

Link copied to clipboard

The content as it was last drawn. Suspends because reading pixels back off the GPU is asynchronous on every platform.