Skip to main content

try_read_texture_rgba

Function try_read_texture_rgba 

Source
pub fn try_read_texture_rgba(
    device: &Device,
    queue: &Queue,
    texture: &Texture,
    width: u32,
    height: u32,
) -> Result<Vec<u8>, ReadbackError>
Expand description

Read a texture back as tightly-packed RGBA.

The GPU copy needs each row aligned to wgpu::COPY_BYTES_PER_ROW_ALIGNMENT; the padding is added for the copy and stripped back out here, so the returned buffer is exactly width * height * 4 bytes with no stride.