otf-pixels-codec-png
PNG for Pixels, written from scratch, DEFLATE included
An Open Tech Foundation project
Decodes every PNG colour type and bit depth and encodes 8 and 16-bit, with its own DEFLATE. Non-interlaced images decode one row at a time.
[!TIP] Building an app or a server? Use
otf-pixelsinstead: it picks this codec from the file's bytes with itspngfeature.
Use it
Transcode row by row, without holding the image:
use ;
use ;
let mut decoder = new?;
let descriptor = decoder.descriptor;
let mut encoder = new;
let mut out = Vecnew;
encoder.write_header?;
let mut row = vec!;
for _ in 0..descriptor.height
encoder.finish?;
Capabilities
| Area | Support |
|---|---|
| Decode | All colour types, 1–16-bit, palettes, tRNS, Adam7 interlace |
| Encode | 8/16-bit grey, RGB and RGBA; adaptive filters; levels via with_level |
| Checked against | libpng: PngSuite decodes match, and libpng reads back every file written |
API
| Item | What it does |
|---|---|
PngDecoder |
Streaming decoder |
PngEncoder |
Encoder; new, with_level, from_options |
PngCodec, probe |
Signature detection |
Header, ColorType, Filter |
The format's own types |
Part of Pixels
| Crate | Role |
|---|---|
otf-pixels |
The chainable Image API most users want |
otf-pixels-core |
Graph, tiles, scheduler, codec and op traits |
otf-pixels-ops |
Image operations |
otf-pixels-compress |
DEFLATE, zlib, LZW, checksums |
otf-pixels-codec-* |
One crate per format |
License
Apache-2.0 — see LICENSE.