code wiki / (root) / nx_ico.nx

nx_ico.nx

buildroot/runtime/nx_ico.nx

7328 B208 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic ico
docsdependenciesstructsconstsfunctions

about

nx_ico.nx -- ICO/CUR icon container: a COMPLETE format, writer and reader. Every site has a favicon and the tree could not read or write one. ICO is a directory of images -- historically DIB bitmaps, and since about 2010 usually PNG for the larger sizes -- so a reader has to dispatch on the payload's own magic rather than on anything in the directory. ZERO MEANS 256. The width and height fields are ONE BYTE each, so 256 -- the standard modern favicon size -- is encoded as 0. A reader that takes the byte at face value reports a 256x256 icon as 0x0 and usually then divides by it or skips it. This is the single most common ICO bug and it only appears at the one size that matters most today. THE DIRECTORY DOES NOT KNOW THE FORMAT. Nothing in an ICONDIRENTRY says whether the payload is a DIB or a PNG; both are legal in the same file, and the bitCount field is frequently zero or wrong for PNG entries. The only reliable discriminator is the payload's first bytes, which is why this module sniffs rather than trusting the header. genealogy_id: microsoft_ico_cur_format lineage_id: nx_ico_v1 license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_ico.nx nx_ico_gate.nx

imports: nx_syscalls.nx

imported by: nx_ico_gate.nx

structs

none

consts

26const NX_ICO_DIR_LEN: i64 = 6
27const NX_ICO_ENTRY_LEN: i64 = 16
28const NX_ICO_TYPE_ICON: i64 = 1
29const NX_ICO_TYPE_CUR: i64 = 2
30const NX_ICO_MAX_DIM: i64 = 256
32const NX_ICO_FLD_WIDTH: i64 = 0
33const NX_ICO_FLD_HEIGHT: i64 = 1
34const NX_ICO_FLD_COLORS: i64 = 2
35const NX_ICO_FLD_PLANES: i64 = 3
36const NX_ICO_FLD_BITS: i64 = 4
37const NX_ICO_FLD_BYTES: i64 = 5
38const NX_ICO_FLD_OFFSET: i64 = 6
39const NX_ICO_FLD_ISPNG: i64 = 7

functions

41func nx_ico_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 }
43func nx_ico_r16(d: *u8, o: i64) -> i64
47func nx_ico_r32(d: *u8, o: i64) -> i64
called by 1: nx_ico_read_entry calls 1: nx_ico_at
52func nx_ico_w16(o: *u8, p: i64, v: i64) -> i64
58func nx_ico_w32(o: *u8, p: i64, v: i64) -> i64
68func nx_ico_dim_decode(b: i64) -> i64
73func nx_ico_dim_encode(v: i64) -> i64
84func nx_ico_is_png(d: *u8, n: i64, off: i64) -> i64
called by 1: nx_ico_read_entry calls 1: nx_ico_at
99func nx_ico_write_begin(o: *u8, cap: i64, count: i64) -> i64
called by 1: main calls 1: nx_ico_w16
110func nx_ico_write_entry(o: *u8, cap: i64, index: i64, data_off: i64,
139func nx_ico_count(d: *u8, n: i64) -> i64
150func nx_ico_read_entry(d: *u8, n: i64, index: i64, fld: *i64) -> i64
182func nx_ico_best(d: *u8, n: i64, target: i64) -> i64