makeNonTextureImage

fun Image.makeNonTextureImage(): Image

Copies this image to the CPU (React Native Skia's SkImage.makeNonTextureImage(), which skiko lacks): the result is a raster image that can be used on any thread, e.g. to display it in the UI or to encode it.

val snapshot = renderToTexture(frame) { (frameTexture, canvas) -> canvas.drawImage(frameTexture, 0f, 0f) }
val cpuImage = snapshot.makeNonTextureImage()
snapshot.close()

A GPU image returned by renderToTexture must be copied on the thread that rendered it.

Throws

If the pixels could not be read, e.g. because a GPU image is copied on another thread.