Skip to main content

decode_png_to_rgba

Function decode_png_to_rgba 

Source
pub fn decode_png_to_rgba(png_bytes: &[u8]) -> Result<(u32, u32, Vec<u8>)>
Expand description

Decode an 8-bit RGBA PNG into a tightly packed, row-major width * height RGBA8 buffer, returning (width, height, rgba). Used by the clipboard-copy shim to turn the figure PNG (the only in-memory figure encoding available here) back into the RGBA the clipboard expects; the figure encoder (encode_png) always writes 8-bit RGBA, so no channel expansion is needed. Returns an error for a non-RGBA8 PNG. Pure (no GPU/clipboard), so the decode is testable via an encode_png round-trip.