DVUI

readTarget

Read pixels from texture created with textureCreateTarget.

Returns pixels allocated by arena.

Only valid between Window.beginand Window.end.

Parameters

#
arena:std.mem.Allocator
std.mem.Allocator
texture:Target
Target

Source

Implementation

#
pub fn readTarget(arena: std.mem.Allocator, texture: Target) TextureError![]Color.PMA {
    const size: usize = texture.width * texture.height * @sizeOf(Color.PMA);
    const pixels = try arena.alloc(u8, size);
    errdefer arena.free(pixels);

    try dvui.currentWindow().backend.textureReadTarget(texture, pixels.ptr);

    return @ptrCast(pixels);
}