code wiki / (root) / nx_png_capacity_t278.nx

nx_png_capacity_t278.nx

buildroot/runtime/nx_png_capacity_t278.nx

16692 B340 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind orphan librarytopic png
docsdependenciesstructsconstsfunctions

about

nx_png.nx -- SOVEREIGN PNG (RGB8) encoder in NishiLang. No zlib/libpng/python: adaptive per-scanline FILTERING (None/Sub/Up/Avg/Paeth, min-abs-sum heuristic) + REAL DEFLATE compression (nx_deflate_enc, LZ77 + fixed Huffman) -- so renders ship compact + full-resolution. CRC32 (chunk) + Adler32 (zlib) pure integer. Upgraded 2026-07-04 from stored (uncompressed) blocks; same write_png() contract, valid PNG out, much smaller. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_deflate_enc_capacity_t278.nx nx_png_capacity_t278.nx

imports: nx_syscalls.nxnx_deflate_enc_capacity_t278.nx

imported by: nobody (leaf or entry point)

structs

none

consts

8const PNG_ZLIB_HDR_BYTES: i64 = 2 // 0x78 0x01
9const PNG_ADLER_BYTES: i64 = 4 // adler32 trailer of the zlib stream
10const K_MAGIC_65521: i64 = 65521
11const K_MAGIC_65536: i64 = 65536
16const PNG_DEFLATE_RESERVE_BYTES: i64 = 128
17const PNG_DEFLATE_EXPAND_DIV: i64 = 2 // + rawlen/2 headroom for an incompressible worst case
216const PNG_MODE_0644: i64 = 0x1a4
219const PNG_ANN_FD: i64 = 1
221const PNG_I64_MAX_DIGITS: i64 = 19
223const PNG_SIG_BYTES: i64 = 8 // 137 P N G CR LF SUB LF
224const PNG_IHDR_CHUNK_BYTES: i64 = 25 // 4 length + 4 type + 13 data + 4 crc
225const PNG_CHUNK_FRAME_BYTES: i64 = 12 // 4 length + 4 type + 4 crc -- once for IDAT, once for IEND
228const PNG_ERR_SHORT_WRITE: i64 = 1001
229const PNG_ERR_NOT_ON_DISK: i64 = 1002

functions

19func png_crc32(buf: *u8, off: i64, len: i64) -> i64
34func png_adler32(buf: *u8, off: i64, len: i64) -> i64
45func png_be32(b: *u8, o: i64, v: i64) -> i64
52func png_paeth(a: i64, b: i64, c: i64) -> i64 { // a=left b=up c=upleft
64func png_sabs(v: i64) -> i64 { var x: i64 = v & 0xff; if x > 127 { x = 256 - x } return x }
65func png_g(img: *u8, w3: i64, r: i64, j: i64) -> i64 { // safe fetch, 0 outside bounds
74func png_chunk_length_valid(n:i64)->i64 { return n>=0 && n<=2147483647 }
76func write_png_buf_checked(fb: *i64, fb_pixels:i64, w: i64, h: i64, out: *u8, capacity:i64) -> i64
177func write_png_buf(fb:*i64,w:i64,h:i64,out:*u8)->i64
231func pngw_emit(s: *u8) -> i64
called by 1: png_publish calls 1: sys_write
237func pngw_num(v: i64) -> i64
called by 1: png_publish calls 2: sys_mmapsys_write
255func png_buf_cap(w:i64,h:i64)->i64
271func png_publish(fb: *i64, w: i64, h: i64, path: *u8, ann: i64) -> i64
329func png_publish_announced(fb: *i64, w: i64, h: i64, path: *u8) -> i64
calls 1: png_publish
336func write_png(fb: *i64, w: i64, h: i64, path: *u8) -> i64
calls 1: png_publish