captureToImage

fun captureToImage(activity: Activity, composable: @Composable () -> Unit): ImageBitmap

Should be called from the main thread. You can use Activity.runOnUiThread if you are on another thread. For Kotlin coroutines, use the below code if your coroutine is on another thread:

val image = withContext(Dispatchers.Main) {
captureToImage(myActivity/*OR this*/, composable)
}

actual fun captureToImage(composable: () -> Unit): ImageBitmap
expect fun captureToImage(composable: @Composable () -> Unit): ImageBitmap
actual fun captureToImage(composable: () -> Unit): ImageBitmap
actual fun captureToImage(composable: () -> Unit): ImageBitmap
actual fun captureToImage(composable: () -> Unit): ImageBitmap
actual fun captureToImage(composable: () -> Unit): ImageBitmap