Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.
Dependency-free PNG encoder and decoder for the agent feedback loop.
The renderer's pixel format is RGBA8, sRGB, straight (non-premultiplied)
alpha, top-left origin, tightly packed. That is exactly PNG color type 6,
so no (un)premultiplication is needed: bytes are written verbatim. Use
[composite_over] when an opaque picture is wanted.
Encoding is deterministic: identical pixels give byte-identical files. The
encoder picks a per-row PNG filter by the standard minimum-sum-of-absolute-
differences heuristic and compresses with either stored deflate blocks or a
single fixed-Huffman block with greedy LZ77 matching ([Compression]).
The decoder reads non-interlaced grayscale (1, 2, 4, 8, 16 bit), gray+alpha, RGB, RGBA (8, 16 bit) and palette (1, 2, 4, 8 bit,
with tRNS) PNGs (stored, fixed and dynamic deflate), verifying chunk CRCs and Adler-32.
Enums
enumaster_blueprint::png::Compression
pub enum Compression { Stored, Fixed }Compression of the zlib stream inside the PNG.
Variants
Stored— Uncompressed deflate stored blocks: fastest, largest.Fixed— One fixed-Huffman block with LZ77 matching (default).
Trait implementations: Clone, Copy, Debug, Default, Eq, PartialEq, StructuralPartialEq
enumaster_blueprint::png::PngError
pub enum PngError { BadDimensions, Unsupported, Corrupt, Io }PNG encode/decode failure.
Variants
BadDimensions— Zero-sized, oversized, orpixels.len() != w * h * 4.Unsupported— Not a PNG this decoder understands (message says why).Corrupt— Corrupt stream (bad CRC, Adler, deflate, filter or chunk layout).Io
Trait implementations: Debug, Display, Error, From<Error>
Functions
fnaster_blueprint::png::adler32
pub fn adler32(data: &[u8]) -> u32Adler-32 (zlib trailer).
fnaster_blueprint::png::composite_over
pub fn composite_over(pixels: &[u8], background: [u8; 3]) -> Vec<u8>Source over an opaque background: converts straight-alpha RGBA8 into opaque RGBA8 (alpha 255), rounding to nearest.
fnaster_blueprint::png::crc32
pub fn crc32(data: &[u8]) -> u32CRC-32 (IEEE 802.3, as used by PNG chunks).
fnaster_blueprint::png::decode_rgba
pub fn decode_rgba(bytes: &[u8]) -> Result<(u32, u32, Vec<u8>), PngError>Decode a PNG into (width, height, straight-alpha RGBA8): gray, gray+alpha, RGB, RGBA and palette images (with tRNS
transparency), at the bit depths the format allows (1, 2, 4, 8, 16; 16-bit samples keep their high byte); not interlaced.
fnaster_blueprint::png::deflate_fixed
pub fn deflate_fixed(data: &[u8]) -> Vec<u8>Raw deflate, one final fixed-Huffman block.
fnaster_blueprint::png::deflate_stored
pub fn deflate_stored(data: &[u8]) -> Vec<u8>Raw deflate using only stored blocks.
fnaster_blueprint::png::encode_rgba
pub fn encode_rgba(width: u32, height: u32, pixels: &[u8], compression: Compression) -> Result<Vec<u8>, PngError>Encode straight-alpha RGBA8 pixels as a PNG byte vector.
fnaster_blueprint::png::inflate
pub fn inflate(data: &[u8], limit: usize) -> Result<Vec<u8>, PngError>Inflate a raw deflate stream (stored, fixed and dynamic blocks).
Output beyond limit bytes is refused.
fnaster_blueprint::png::read_rgba
pub fn read_rgba(path: impl AsRef<std::path::Path>) -> Result<(u32, u32, Vec<u8>), PngError>Read a PNG file into (width, height, straight-alpha RGBA8).
fnaster_blueprint::png::write_rgba
pub fn write_rgba(path: impl AsRef<std::path::Path>, width: u32, height: u32, pixels: &[u8]) -> Result<(), PngError>Write straight-alpha RGBA8 pixels to path as a PNG (default compression).
Parent directories are created.
fnaster_blueprint::png::write_rgba_with
pub fn write_rgba_with(path: impl AsRef<std::path::Path>, width: u32, height: u32, pixels: &[u8], compression: Compression) -> Result<(), PngError>As [write_rgba] with an explicit [Compression].
fnaster_blueprint::png::zlib
pub fn zlib(data: &[u8], compression: Compression) -> Vec<u8>zlib wrapper (RFC 1950) around deflate.
Constants
constaster_blueprint::png::MAX_DECODED_BYTES
pub const MAX_DECODED_BYTES: usizeLargest decoded pixel buffer (bytes) the decoder will allocate.