mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-12 10:03:51 +00:00
The format half of PhotoCraft's Paint.NET import (crates/io/src/pdn.rs and pdn/nrbf.rs at abeb16c96): the PDN3 header, the .NET binary serialization graph, the layer list and blend modes, and the chunked gzip pixel blocks. Surfaces, blend-mode mapping and warnings stay in the app.
craft-pdn
Paint.NET documents (.pdn), read. Only the PDN3 layout (Paint.NET 3 and 4): the PDN3
signature, an XML header (skipped), a .NET binary serialization stream holding a
PaintDotNet.Document, then one block of pixels per surface in numbered chunks, each a gzip
stream or raw bytes. The layout follows the reader of the pypdn project (MIT); the serialization
records follow Microsoft's public MS-NRBF specification.
is_pdn: the signature.Document::parse: canvas size, bitmap layers (name, visibility, opacity 0 to 255, Paint.NET's ownBlendMode, from the currentblendModefield or the olderUserBlendOpsclass names) and which surface each layer shows. Every allocation the pixels need is checked first.Document::read_surfaces: decodes the pixel blocks in file order, oneSurface(rows of B, G, R, A bytes, straight alpha) at a time, with akeep_goingcallback.nrbf: the data-only MS-NRBF reader on its own: aGraphofValues with references kept as ids. No .NET type is instantiated or run.
Paint.NET's Color Burn and Color Dodge are its own formulas; what an application maps them to is its own choice. There is no writer.
Limits
| Limit | Value |
|---|---|
| Canvas, and all pixel blocks together | 1 GiB (MAX_PIXEL_BYTES) |
| Layers | 1 to 1024 (MAX_LAYERS) |
| A layer name; all names | 64 KiB (MAX_NAME_BYTES); 4 MiB (MAX_TOTAL_NAME_BYTES) |
| Pixel chunks in one block | 1,000,000 |
| NRBF records, items and members | 1,000,000 (nrbf::MAX_ITEMS) |
| NRBF string bytes | 64 MiB (nrbf::MAX_STRINGS) |
| NRBF nesting and reference chains | 64 (nrbf::MAX_DEPTH) |
A raw pixel block shorter than it declares is refused before its buffer is allocated.