diff --git a/Cargo.toml b/Cargo.toml index 673a02e..b422a4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,4 +16,5 @@ flate2 = "1.0.25" image = { version = "0.24.5", default-features = false, features = ["png"] } [features] +# re-exports png crate png = [] diff --git a/README.md b/README.md index 6c460eb..8faec0c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ apng is animated png encoder for Rust, and made in pure Rust. ## Example usage ```rust +use apng::{Encoder, Frame, PNGImage}; +use std::fs::File; +use std::io::BufWriter; +use std::path::Path; + fn main() { let files = vec![ "rust_logo1.png", diff --git a/src/lib.rs b/src/lib.rs index 75ecb58..f626a13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,56 @@ +/*! +apng is animated png encoder for Rust, and made in pure Rust. + + + +# Example + +```no_run +use apng::{Encoder, Frame, PNGImage}; +use std::fs::File; +use std::io::BufWriter; +use std::path::Path; + +fn main() { + let files = vec![ + "rust_logo1.png", + "rust_logo2.png", + "rust_logo3.png", + "rust_logo4.png", + "rust_logo5.png", + "rust_logo6.png", + ]; + + let mut png_images: Vec = Vec::new(); + for f in files.iter() { + png_images.push(apng::load_png(f).unwrap()); + } + + let path = Path::new(r"sample/out.png"); + let mut out = BufWriter::new(File::create(path).unwrap()); + + let config = apng::create_config(&png_images, None).unwrap(); + let mut encoder = Encoder::new(&mut out, config).unwrap(); + let frame = Frame { + delay_num: Some(1), + delay_den: Some(2), + ..Default::default() + }; + + match encoder.encode_all(png_images, Some(&frame)) { + Ok(_n) => println!("success"), + Err(err) => eprintln!("{}", err), + } +} +``` + + +# Feature Flags + +- `png`: re-exports the types from `png` crate + +*/ + mod apng; pub mod errors; mod png;