diff options
author | pommicket <pommicket@gmail.com> | 2025-09-08 15:02:43 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-08 15:11:36 -0400 |
commit | 4891fa07a51f8da70773cbdbc64ff3aa7ebecf58 (patch) | |
tree | 6ccb068bbcd4d1df039f70b5c1fd2c83724c9282 /README.md | |
parent | ea5bb4e9f7736fcd54fa2bff82402f3a6eb5748f (diff) |
Update to latest version of png crate
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -3,7 +3,7 @@ [crates.io page](https://crates.io/crates/minipng) · [repository](https://github.com/pommicket/minipng) Tiny Rust PNG decoder with no dependencies (not even `std` or `alloc`) -and tiny code size (e.g. >8 times smaller `.wasm.gz` size compared to the `png` crate — see `check-size.sh`). +and tiny code size (e.g. ~9 times smaller `.wasm.gz` size compared to the `png` crate). ## Goals @@ -30,7 +30,7 @@ Basic usage: ```rust let mut buffer = vec![0; 1 << 20]; // hope this is big enough! -let png = &include_bytes!("../examples/image.png")[..]; +let png = &include_bytes!("examples/image.png")[..]; let image = minipng::decode_png(png, &mut buffer).expect("bad PNG"); println!("{}×{} image", image.width(), image.height()); let pixels = image.pixels(); @@ -41,7 +41,7 @@ println!("top-left pixel is #{:02x}{:02x}{:02x}", pixels[0], pixels[1], pixels[2 More complex example that allocates the right number of bytes and handles all color formats: ```rust -let png = &include_bytes!("../examples/image.png")[..]; +let png = &include_bytes!("examples/image.png")[..]; let header = minipng::decode_png_header(png).expect("bad PNG"); let mut buffer = vec![0; header.required_bytes_rgba8bpc()]; let mut image = minipng::decode_png(png, &mut buffer).expect("bad PNG"); @@ -72,8 +72,8 @@ tests and no way of enabling `--nocapture` by default *grumble grumble*). ## Performance -Benchmarks (see `cargo bench`) show that `minipng` is about 50% slower than the `png` crate -for large images, but faster than `png` for small images. +Benchmarks (see `cargo bench`) show that `minipng` is about 2× slower than the `png` crate +for large images, but about the same for small images. ## License |