Skip to content

Commit

Permalink
docs: add crate documentation (#39)
Browse files Browse the repository at this point in the history
* docs: add crate documentation

* fix: add imports
  • Loading branch information
orhun authored Feb 14, 2024
1 parent 17888d1 commit 97555ce
Show file tree
Hide file tree
Showing 3 changed files with 59 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 = []
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
53 changes: 53 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
/*!
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
```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<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 97555ce

Please sign in to comment.