spng 0.1.0

Rust bindings to libspng

PNG image decoding

Rust bindings to libspng.


# static TEST_PNG: &[u8] = include_bytes!("../tests/test-001.png");
let cursor = std::io::Cursor::new(TEST_PNG);
let decoder = spng::Decoder::new(cursor);
let (out_info, mut reader) = decoder.read_info()?;
let output_buffer_size = reader.output_buffer_size();
assert_eq!(300, out_info.width);
assert_eq!(300, out_info.height);
assert_eq!(8, out_info.bit_depth as u8);
assert_eq!(4, out_info.color_type.samples());
assert_eq!(out_info.buffer_size, output_buffer_size);
let mut out = vec![0; output_buffer_size];
reader.next_frame(&mut out)?;
# Ok::<(), Box<dyn std::error::Error>>(())