Image module

decode_bmp

procedureextensionsince 0.28.0Source

Decodes a BMP file of 1, 4, 8 (palette, optionally RLE), 16, 24 or 32 bits per pixel. Palette and 24-bit images become RGB8; 16 and 32-bit images become RGBA8 when they have alpha, RGB8 otherwise.

Example↗
bmp := encode_bmp(make_image(3, 3, .RGB8));
defer free(bmp.data);

image, ok := decode_bmp(bmp);
defer deinit(*image);
assert(ok && image.width == 3);
decode_bmp :: (
    data: [] u8,
    max_pixels: s64 = DEFAULT_MAX_PIXELS
) -> (image: Image, ok: bool, error: string)

Parameters

data: [] u8
max_pixels: s64 = DEFAULT_MAX_PIXELS

Returns

image: Image
ok: bool
error: string

See also