nx_ico_decode.nx
buildroot/runtime/nx_ico_decode.nx
about
nx_ico_decode.nx -- Windows ICO/CUR reader. The one legacy format with
LIVE web demand: every favicon.ico a crawler meets is this.
AN ICO IS A CONTAINER, NOT AN IMAGE. It holds N frames at different sizes,
and the entry's width/height byte is 0 for 256 -- a reader that takes the
byte literally reports a 0x0 image for the largest frame there is. We pick
the LARGEST frame by area (that is what a fingerprint wants) and decode it.
A frame is EITHER a PNG (modern, and the only way 256x256 is normally
stored) OR a headerless BITMAPINFOHEADER DIB. The DIB's declared height is
DOUBLE the real height because an AND (transparency) mask is appended below
the XOR (colour) rows; halving it is not a heuristic, it is the format.
The mask itself is ignored: a fingerprint wants pixels, not alpha.
genealogy_id: msdn_ico_format
lineage_id: nx_ico_v1
license_tier: ORIGINAL
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_png_decoder.nx
imported by: nx_img_bytes_to_rgb.nxnx_legacy_codec_gate.nx
structs
| none |
consts
| none |
functions
| 22 | func ico_b(d: *u8, o: i64) -> i64 { return (d[o] as i64) & 255 } |
| 23 | func ico_u16(d: *u8, o: i64) -> i64 { return ico_b(d,o) | (ico_b(d,o+1) << 8) } |
| 24 | func ico_u32(d: *u8, o: i64) -> i64 |
| 29 | func ico_dib_rgb(raw: *u8, n: i64, off: i64, len: i64, out_wh: *i64) -> *u8 |
| 96 | func ico_decode_rgb(raw: *u8, n: i64, out_wh: *i64) -> *u8 |