Expand description
A library for decoding and encoding PNG images and APNG animations.
§Getting Started
Add the following to your Cargo.toml
.
[dependencies.png_pong]
version = "0.9"
§Example
// Saving raster as a PNG file
let raster = png_pong::PngRaster::Rgba8(pix::Raster::with_pixels(1, 1, &[
pix::rgb::SRgba8::new(0, 0, 0, 0)][..]
));
let mut out_data = Vec::new();
let mut encoder = png_pong::Encoder::new(&mut out_data).into_step_enc();
let step = png_pong::Step{ raster, delay: 0 };
encoder.encode(&step).expect("Failed to add frame");
std::fs::write("graphic.png", out_data).expect("Failed to save image");
// Loading PNG file into a Raster
let data = std::fs::read("graphic.png").expect("Failed to open PNG");
let data = std::io::Cursor::new(data);
let decoder = png_pong::Decoder::new(data).expect("Not PNG").into_steps();
let png_pong::Step { raster, delay } = decoder
.last()
.expect("No frames in PNG")
.expect("PNG parsing error");
Modules§
- Low-level PNG API
- PNG file decoding
- PNG file encoding
Structs§
- PNG file decoder
- PNG file encoder
- A Frame
Enums§
- A Raster of one of the PNG types (all are sRGB gamma). PNGs with less than 8 bits per channel are scaled up to 8 bits per channel.