Ico_File module

create_ico_file

procedureSource

Makes Windows ICO files from pictures: create_ico_file from pixels, or create_ico_file_from_bitmap_filename from an image file. Each icon holds five sizes, 256 down to 16.

create_ico_file :: (x: s32, y: s32, comp: s32, image_data: *u8) -> string

Builds an ICO file from a picture of x by y pixels, scaled to 256, 128, 48, 32 and 16 pixels square. image_data is tightly packed BGR (comp 3) or BGRA (comp 4). Returns the file's bytes (free them), or an empty string after logging an error.

Parameters

x: s32
y: s32
comp: s32
image_data: *u8

Returns

string
Example
pixels: [16] u8;
ico := create_ico_file(2, 2, 4, pixels.data);
defer free(ico);
assert(ico.count > 0);

Doesn't run in the browser (skipped on wasm).

See also