readPixels

@PlatformGap(platforms = [FilamentPlatform.WEB], behavior = "delivers asynchronously — the pixels are copied into the buffer when the frame completes, before its callback runs, rather than on return.")
fun readPixels(xoffset: Int, yoffset: Int, width: Int, height: Int, buffer: Texture.PixelBufferDescriptor)

Read back SwapChain pixels asynchronously.

The buffer's callback is invoked on the main thread when complete (usually after several endFrame() calls). Formats RGBA/RGBA_INTEGER and types UBYTE/UINT/INT/FLOAT are always supported.

Call between beginFrame() and endFrame(), typically after render(). Impacts performance significantly, especially on some mobile platforms.

Parameters

xoffset

Left offset in pixels.

yoffset

Bottom offset in pixels.

width

Width in pixels.

height

Height in pixels.

buffer

Pixel buffer descriptor for the result.


fun readPixels(xoffset: Int, yoffset: Int, width: Int, height: Int, address: NativePointer, sizeInBytes: Int, format: Texture.Format, type: Texture.Type, stride: Int, onDone: () -> Unit)

readPixels straight into native memory the caller owns, without a copy (e.g. a Skia bitmap's pixels). onDone runs once address holds the frame, possibly on Filament's driver thread.


@PlatformGap(platforms = [FilamentPlatform.WEB], behavior = "delivers asynchronously — the pixels are copied into the buffer when the frame completes, before its callback runs, rather than on return.")
fun readPixels(renderTarget: RenderTarget, xoffset: Int, yoffset: Int, width: Int, height: Int, buffer: Texture.PixelBufferDescriptor)

Read back RenderTarget pixels asynchronously.

Similar to readPixels(SwapChain), but reads from a RenderTarget instead.

Parameters

renderTarget

RenderTarget to read from.

xoffset

Left offset in pixels.

yoffset

Bottom offset in pixels.

width

Width in pixels.

height

Height in pixels.

buffer

Pixel buffer descriptor for the result.