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])
| 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. |
| 145 | pub(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 | } |
no outgoing calls
no test coverage detected