Skip to content

Commit

Permalink
docs: add crate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Feb 14, 2024
1 parent 17888d1 commit 72ec0fa
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ flate2 = "1.0.25"
image = { version = "0.24.5", default-features = false, features = ["png"] }

[features]
# re-exports png crate
png = []
48 changes: 48 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
/*!
apng is animated png encoder for Rust, and made in pure Rust.
<img src="https://raw.githubusercontent.com/poccariswet/apng/master/examples/_rust_logo/out.png" width="250">
# Example
```rust
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<PNGImage> = 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;
Expand Down

0 comments on commit 72ec0fa

Please sign in to comment.