MoonPNG is a pure MoonBit PNG parser and decoder. It validates the PNG
container, inflates zlib/DEFLATE image data, reverses PNG scanline filters, and
returns portable RGBA8 pixels without FFI or platform-specific dependencies.
The zlib layer is also reusable on its own through inflate_zlib and
inflate_zlib_with_limit.
Architecture
The decode pipeline has five bounded stages:
inspect and validate the PNG container;
validate palette and transparency metadata;
concatenate consecutive IDAT payloads;
inflate the zlib stream and verify Adler-32;
reverse row filters, unpack samples, and convert them to RGBA8.
See DESIGN.md for the invariants and module boundaries.
Roadmap
Decode 16-bit samples with documented RGBA8 downsampling.
Add Adam7 interlace reconstruction.
Add deterministic PNG encoding and streaming interfaces.
Add a browser demo, conformance fixtures, fuzzing, and benchmarks.
Project status
This repository is being developed for the 2026 MoonBit open-source ecosystem
competition. The implementation is original MoonBit code based on public PNG,
zlib, and DEFLATE specifications. See SOURCES.md for provenance
notes.
MoonPNG
MoonPNG is a pure MoonBit PNG parser and decoder. It validates the PNG container, inflates zlib/DEFLATE image data, reverses PNG scanline filters, and returns portable RGBA8 pixels without FFI or platform-specific dependencies.
Repository: https://github.com/cn-cheems/moonpng
Current capabilities
PLTEpalettes;tRNStransparency for grayscale, truecolor, and indexed images;16-bit samples and Adam7 interlacing are planned work and currently return explicit unsupported-feature errors.
Quick start
Expected demo output:
Decode an image
DecodedImage.pixelsstores four bytes per pixel in red, green, blue, alpha order. Rows are contiguous from top to bottom.Inspect without decoding
Use
inspectwhen only container metadata and chunk information are needed:Resource limits
The default decoder uses conservative bounds suitable for ordinary images. Applications can choose tighter limits for untrusted uploads:
The zlib layer is also reusable on its own through
inflate_zlibandinflate_zlib_with_limit.Architecture
The decode pipeline has five bounded stages:
See DESIGN.md for the invariants and module boundaries.
Roadmap
Project status
This repository is being developed for the 2026 MoonBit open-source ecosystem competition. The implementation is original MoonBit code based on public PNG, zlib, and DEFLATE specifications. See SOURCES.md for provenance notes.
License
Apache-2.0.