code wiki / (root) / nx_img_to_rgb.nx

nx_img_to_rgb.nx source

↩ module page · 13 lines · 708 B

1// nx_img_to_rgb.nx -- decode an encoded image FILE -> interleaved 8-bit RGB (w*h*3, row-major). Thin PATH 2// wrapper over nx_img_bytes_to_rgb (the bytes-in core): read the file, then decode. NOT usable from the 3// Windows PE (no sys_read_file thunk) -- the GUI uses read_local + nx_img_bytes_to_rgb directly. 4// Graceful-degradation contract lives in the bytes core (PNG PARTIAL, JPEG baseline). license_tier: ORIGINAL 5import "nx_syscalls.nx" 6import "nx_img_bytes_to_rgb.nx" 7 8func nx_img_to_rgb(path: *u8, out_wh: *i64) -> *u8 { 9 let box: *i64=sys_mmap(16) as *i64 10 let raw: *u8=sys_read_file(path, box) 11 if raw==(0 as *u8) { return 0 as *u8 } 12 return nx_img_bytes_to_rgb(raw, box[0], out_wh) 13}