PNG Pong - A pure Rust PNG encoder & decoder
This is a pure Rust PNG image decoder and encoder based on lodepng. This crate allows easy reading and writing of PNG files without any system dependencies.
Why another PNG crate?
These are the 3 Rust PNG encoder/decoder crates I know of:
- png - The one everyone uses, is very limited in which PNGs it can open.
- lodepng - Lots of features, code is ported from C, therefore code is hard read & maintain, also uses slow implementation of deflate/inflate algorithm.
- imagefmt - Abandoned, just as limited as png, but with a lot less lines of code.
Originally I made the aci_png based on imagefmt, and intended to add more features. That task seemed possible at first, but just became daunting after a while. That's why I decided to take
lodepng which has more features (and more low level features) and clean up the code, upgrade to 2018 edition of Rust, depend on inflate and deflate crates (because they can do it faster than lodepng) and get rid of the libc dependency so it actually becomes pure Rust (lodepng claims to be, but calls C's malloc and free). I also decided to model the API after the gift crate, so I'm using pix instead of rgb.
- Forbid unsafe.
- APNG support as iterator.
- Compatible with pix / gift-style API.
- Load all PNG files crushed with pngcrush.
- Save crushed PNG files.
- Clean, well-documented, concise code.
- Say you want to read a PNG file into a raster:
let mut decoder_builder = new; let data = read.expect; let data = new; let decoder = decoder_builder.decode_rasters; let = decoder .last .expect .expect;
- Say you want to save a raster as a PNG file.
let raster = new.with_pixels; let mut out_data = Vecnew; let mut encoder = new; let mut encoder = encoder.encode_rasters; encoder.add_frame.expect; write.expect;
- Implement APNG reading.
- Implement Chunk reading (with all the different chunk structs).
- RasterDecoder should wrap ChunkDecoder & RasterEncoder should wrap ChunkEncoder
ParseErrorwith Rust-style enum instead of having a C integer.
- More test cases to test against.