nx_ico.nx
buildroot/runtime/nx_ico.nx
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
imports: nx_syscalls.nx
imported by: nx_ico_gate.nx
structs
| none |
consts
| 26 | const NX_ICO_DIR_LEN: i64 = 6 |
| 27 | const NX_ICO_ENTRY_LEN: i64 = 16 |
| 28 | const NX_ICO_TYPE_ICON: i64 = 1 |
| 29 | const NX_ICO_TYPE_CUR: i64 = 2 |
| 30 | const NX_ICO_MAX_DIM: i64 = 256 |
| 32 | const NX_ICO_FLD_WIDTH: i64 = 0 |
| 33 | const NX_ICO_FLD_HEIGHT: i64 = 1 |
| 34 | const NX_ICO_FLD_COLORS: i64 = 2 |
| 35 | const NX_ICO_FLD_PLANES: i64 = 3 |
| 36 | const NX_ICO_FLD_BITS: i64 = 4 |
| 37 | const NX_ICO_FLD_BYTES: i64 = 5 |
| 38 | const NX_ICO_FLD_OFFSET: i64 = 6 |
| 39 | const NX_ICO_FLD_ISPNG: i64 = 7 |
functions
| 41 | func nx_ico_at(d: *u8, i: i64) -> i64 { return (d[i] as i64) & 255 } |
| 43 | func nx_ico_r16(d: *u8, o: i64) -> i64 |
| 47 | func nx_ico_r32(d: *u8, o: i64) -> i64 |
| 52 | func nx_ico_w16(o: *u8, p: i64, v: i64) -> i64 |
| 58 | func nx_ico_w32(o: *u8, p: i64, v: i64) -> i64 |
| 68 | func nx_ico_dim_decode(b: i64) -> i64 |
| 73 | func nx_ico_dim_encode(v: i64) -> i64 |
| 84 | func nx_ico_is_png(d: *u8, n: i64, off: i64) -> i64 |
| 99 | func nx_ico_write_begin(o: *u8, cap: i64, count: i64) -> i64 |
| 110 | func nx_ico_write_entry(o: *u8, cap: i64, index: i64, data_off: i64, |
| 139 | func nx_ico_count(d: *u8, n: i64) -> i64 |
| 150 | func nx_ico_read_entry(d: *u8, n: i64, index: i64, fld: *i64) -> i64 called by 2: nx_ico_bestmain calls 6: nx_ico_countnx_ico_r32nx_ico_dim_decodenx_ico_atnx_ico_r16nx_ico_is_png |
| 182 | func nx_ico_best(d: *u8, n: i64, target: i64) -> i64 |