Skip to main content

save_image

Function save_image 

Source
pub fn save_image(
    filename: &str,
    data: &[u8],
    width: u32,
    height: u32,
) -> Result<(), ScreenshotError>
Expand description

Saves raw BGRA pixel data to an image file.

§Arguments

  • filename - Output filename (supports .png, .jpg, .jpeg)
  • data - Raw BGRA pixel data (4 bytes per pixel, as from wgpu Bgra8UnormSrgb format)
  • width - Image width in pixels
  • height - Image height in pixels

§Errors

Returns an error if the file cannot be written or format is unsupported.