nx_png_capacity_t278.nx
buildroot/runtime/nx_png_capacity_t278.nx
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
imports: nx_syscalls.nxnx_deflate_enc_capacity_t278.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 8 | const PNG_ZLIB_HDR_BYTES: i64 = 2 // 0x78 0x01 |
| 9 | const PNG_ADLER_BYTES: i64 = 4 // adler32 trailer of the zlib stream |
| 10 | const K_MAGIC_65521: i64 = 65521 |
| 11 | const K_MAGIC_65536: i64 = 65536 |
| 16 | const PNG_DEFLATE_RESERVE_BYTES: i64 = 128 |
| 17 | const PNG_DEFLATE_EXPAND_DIV: i64 = 2 // + rawlen/2 headroom for an incompressible worst case |
| 216 | const PNG_MODE_0644: i64 = 0x1a4 |
| 219 | const PNG_ANN_FD: i64 = 1 |
| 221 | const PNG_I64_MAX_DIGITS: i64 = 19 |
| 223 | const PNG_SIG_BYTES: i64 = 8 // 137 P N G CR LF SUB LF |
| 224 | const PNG_IHDR_CHUNK_BYTES: i64 = 25 // 4 length + 4 type + 13 data + 4 crc |
| 225 | const PNG_CHUNK_FRAME_BYTES: i64 = 12 // 4 length + 4 type + 4 crc -- once for IDAT, once for IEND |
| 228 | const PNG_ERR_SHORT_WRITE: i64 = 1001 |
| 229 | const PNG_ERR_NOT_ON_DISK: i64 = 1002 |
functions
| 19 | func png_crc32(buf: *u8, off: i64, len: i64) -> i64 called by 1: write_png_buf_checked |
| 34 | func png_adler32(buf: *u8, off: i64, len: i64) -> i64 called by 1: write_png_buf_checked |
| 45 | func png_be32(b: *u8, o: i64, v: i64) -> i64 called by 1: write_png_buf_checked |
| 52 | func png_paeth(a: i64, b: i64, c: i64) -> i64 { // a=left b=up c=upleft called by 1: write_png_buf_checked |
| 64 | func png_sabs(v: i64) -> i64 { var x: i64 = v & 0xff; if x > 127 { x = 256 - x } return x } called by 1: write_png_buf_checked |
| 65 | func png_g(img: *u8, w3: i64, r: i64, j: i64) -> i64 { // safe fetch, 0 outside bounds called by 1: write_png_buf_checked |
| 74 | func png_chunk_length_valid(n:i64)->i64 { return n>=0 && n<=2147483647 } called by 1: write_png_buf_checked |
| 76 | func write_png_buf_checked(fb: *i64, fb_pixels:i64, w: i64, h: i64, out: *u8, capacity:i64) -> i64 called by 1: write_png_buf calls 11: png_buf_capsys_mmap_trysys_munmap_directpng_gpng_paethpng_sabs+5 |
| 177 | func write_png_buf(fb:*i64,w:i64,h:i64,out:*u8)->i64 |
| 231 | func pngw_emit(s: *u8) -> i64 |
| 237 | func pngw_num(v: i64) -> i64 |
| 255 | func png_buf_cap(w:i64,h:i64)->i64 |
| 271 | func png_publish(fb: *i64, w: i64, h: i64, path: *u8, ann: i64) -> i64 |
| 329 | func png_publish_announced(fb: *i64, w: i64, h: i64, path: *u8) -> i64 calls 1: png_publish |
| 336 | func write_png(fb: *i64, w: i64, h: i64, path: *u8) -> i64 calls 1: png_publish |