code wiki / (root) / nx_ico_decode.nx

nx_ico_decode.nx

buildroot/runtime/nx_ico_decode.nx

6338 B167 linesdepth 8pulls 11 transitivereach 37 importersview sourcekind librarytopic ico
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_png_decoder.nx nx_ico_decode.nx nx_img_bytes_to_rgb.nx nx_legacy_codec_gate.nx

imports: nx_syscalls.nxnx_png_decoder.nx

imported by: nx_img_bytes_to_rgb.nxnx_legacy_codec_gate.nx

structs

none

consts

none

functions

22func ico_b(d: *u8, o: i64) -> i64 { return (d[o] as i64) & 255 }
23func ico_u16(d: *u8, o: i64) -> i64 { return ico_b(d,o) | (ico_b(d,o+1) << 8) }
called by 2: ico_dib_rgbico_decode_rgb calls 1: ico_b
24func ico_u32(d: *u8, o: i64) -> i64
called by 2: ico_dib_rgbico_decode_rgb calls 1: ico_b
29func ico_dib_rgb(raw: *u8, n: i64, off: i64, len: i64, out_wh: *i64) -> *u8
96func ico_decode_rgb(raw: *u8, n: i64, out_wh: *i64) -> *u8