code wiki / (root) / nx_bmp_header.nx

nx_bmp_header.nx

buildroot/runtime/nx_bmp_header.nx

5190 B153 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic bmp
docsdependenciesstructsconstsfunctions

about

bmp_header.nx -- parse Windows BMP/DIB image headers. BMP is two concatenated structures: 1. BITMAPFILEHEADER (14 bytes, fixed): 0 2 bfType "BM" = 0x42 0x4D 2 4 bfSize total file size LE 6 2 bfReserved1 8 2 bfReserved2 10 4 bfOffBits offset of pixel data from file start 2. DIB header; the first u32 LE is its size, which discriminates: 12 = BITMAPCOREHEADER (OS/2 1.x) 40 = BITMAPINFOHEADER (Windows 3.0+, the common case) 52 = BITMAPV2INFOHEADER 56 = BITMAPV3INFOHEADER 108 = BITMAPV4HEADER 124 = BITMAPV5HEADER We parse the BMP file header and the first two u32s of the DIB (its size + width), plus the canonical BITMAPINFOHEADER fields when size >= 40. Later DIB-version extensions are surfaced only by their presence (size value). Invariants: B1 Magic "BM" (0x4D42 LE) required. B2 dib_size must be one of the canonical sizes. B3 Height may be negative in BITMAPINFOHEADER -- means top-down. We surface raw signed value; caller picks orientation.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_bmp_header.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap bmp_parse_header bmp_read_u32 bmp_dib_known bmp_read_u16 bmp_read_i32 bmp_read_u32 ↻

structs

42struct BmpHeader

consts

38const BMP_ERR_FORMAT: i64 = -1
39const BMP_ERR_SHORT: i64 = -2
40const BMP_ERR_DIB: i64 = -3

functions

54func bmp_read_u16(buf: *u8, off: i64) -> i64
called by 1: bmp_parse_header
58func bmp_read_u32(buf: *u8, off: i64) -> i64
67func bmp_read_i32(buf: *u8, off: i64) -> i64
called by 1: bmp_parse_header calls 1: bmp_read_u32
76func bmp_dib_known(size: i64) -> i64
called by 1: bmp_parse_header
86func bmp_parse_header(buf: *u8, n: i64, h: *BmpHeader) -> i64
118func main() -> i64