code wiki / (root) / nx_pnm_decode.nx

nx_pnm_decode.nx

buildroot/runtime/nx_pnm_decode.nx

5858 B187 linesdepth 2pulls 2 transitivereach 37 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_pnm_decode.nx -- Netpbm reader: P1/P2/P3 (ASCII) and P4/P5/P6 (binary), the Unix lingua franca that every 90s toolchain could emit. EXACTLY ONE WHITESPACE BYTE FOLLOWS THE HEADER of a binary variant, and the payload starts immediately after it. Skipping "whitespace" greedily eats the first pixel row whenever that row happens to begin with 0x20 or 0x0A -- a corruption that appears only on some images, which is the worst kind. COMMENTS MAY APPEAR BETWEEN ANY TWO HEADER FIELDS, including in the middle of the dimensions, so comment skipping belongs in the token reader rather than in a one-shot header pre-pass. P1/P4 bitmaps invert the usual convention: 1 means BLACK. genealogy_id: netpbm_pnm lineage_id: nx_pnm_v1 license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_pnm_decode.nx nx_img_bytes_to_rgb.nx nx_legacy_codec_gate.nx

imports: nx_syscalls.nx

imported by: nx_img_bytes_to_rgb.nxnx_legacy_codec_gate.nx

structs

none

consts

none

functions

21func pnm_b(d: *u8, o: i64) -> i64 { return (d[o] as i64) & 255 }
23func pnm_is_ws(c: i64) -> i64
35func pnm_tok(raw: *u8, n: i64, pos: *i64) -> i64
called by 1: pnm_decode_rgb calls 2: pnm_bpnm_is_ws
78func pnm_decode_rgb(raw: *u8, n: i64, out_wh: *i64) -> *u8