MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / encode_png_simple

Function encode_png_simple

native/shared/src/renderer/util.rs:145–151  ·  view source on GitHub ↗

Encode an RGB byte buffer (no alpha) as a PNG. Used by the pending-screenshot path so callers can hand us a path and get a PNG written to disk without worrying about cross-FFI buffer handoff.

(width: u32, height: u32, rgb: &[u8])

Source from the content-addressed store, hash-verified

143/// pending-screenshot path so callers can hand us a path and get a
144/// PNG written to disk without worrying about cross-FFI buffer handoff.
145pub(super) fn encode_png_simple(width: u32, height: u32, rgb: &[u8]) -> Option<Vec<u8>> {
146 use image::{ImageBuffer, Rgb};
147 let buf: ImageBuffer<Rgb<u8>, Vec<u8>> = ImageBuffer::from_raw(width, height, rgb.to_vec())?;
148 let mut out = std::io::Cursor::new(Vec::new());
149 buf.write_to(&mut out, image::ImageFormat::Png).ok()?;
150 Some(out.into_inner())
151}

Callers 2

end_frame_with_sceneMethod · 0.85
dump_shadow_cascadeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected