code wiki / (root) / nx_tga_decode.nx

nx_tga_decode.nx

buildroot/runtime/nx_tga_decode.nx

5821 B166 linesdepth 2pulls 2 transitivereach 37 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_tga_decode.nx -- Truevision TGA reader (the DOS/Amiga-era workhorse). Types handled: 1/9 colour-mapped (8-bit index), 2/10 truecolour (16/24/32), 3/11 grayscale (8) -- the 9/10/11 variants being the RLE forms of the same pixel layouts, which is why the RLE unpack sits BEFORE the pixel decode and both paths share it. Refused: types 32/33 (Huffman+delta), colour maps whose entry size is not 15/16/24/32. THE ORIGIN BIT IS NOT DECORATION. Bit 5 of the image descriptor selects top-left vs bottom-left row order. A reader that ignores it returns a vertically MIRRORED image that is otherwise perfectly valid-looking -- the single most common TGA defect, and invisible to any check that only compares dimensions or means. 16-bit is A1R5G5B5 with 5-bit channels replicated to 8 (v<<3|v>>2), NOT shifted-and-zero-filled: the latter loses white (31 -> 248, never 255). genealogy_id: tga_spec_2_0 lineage_id: nx_tga_v1 license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_tga_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

24func tga_b(d: *u8, o: i64) -> i64 { return (d[o] as i64) & 255 }
25func tga_u16(d: *u8, o: i64) -> i64 { return tga_b(d,o) | (tga_b(d,o+1) << 8) }
called by 2: tga_pxtga_decode_rgb calls 1: tga_b
28func tga_x5(v: i64) -> i64 { return (v << 3) | (v >> 2) }
called by 1: tga_px
32func tga_px(src: *u8, so: i64, bpp: i64, rgb: *u8, dof: i64) -> i64
called by 1: tga_decode_rgb calls 3: tga_btga_u16tga_x5
55func tga_unrle(raw: *u8, n: i64, start: i64, npix: i64, bpp: i64, out: *u8) -> i64
called by 1: tga_decode_rgb calls 1: tga_b
86func tga_decode_rgb(raw: *u8, n: i64, out_wh: *i64) -> *u8