Module: graphics.image.bmp

Source: ./graphics/image/bmp.reef


Overview

graphics/image/bmp.reef - BMP file format loader and writer Part of reef-stdlib graphics module

This module provides BMP (Windows Bitmap) file loading and saving. Loader supports: 24-bit RGB, 32-bit RGBA, 8-bit indexed color. Writer emits uncompressed BI_RGB at 24bpp (BGR) or 32bpp (BGRA).


Types

BmpFileHeader

BITMAPFILEHEADER (14 bytes)

Fields:

Name Type
signature int
file_size int
reserved1 int
reserved2 int
data_offset int

BmpInfoHeader

BITMAPINFOHEADER (40 bytes) - most common

Fields:

Name Type
header_size int
width int
height int
planes int
bits_per_pixel int
compression int
image_size int
x_pixels_per_meter int
y_pixels_per_meter int
colors_used int
colors_important int

Functions

fn make_bmp_error(msg: string): result.Result[image.Image, error.Error]

Err carries the message. The old BmpResult had to allocate a dummy 0x0 image just to fill a field the caller was never meant to read.

fn make_bmp_ok(img: image.Image): result.Result[image.Image, error.Error]

fn read_u8(data: [int], offset: int): int

fn read_u16_le(data: [int], offset: int): int

fn read_i32_le(data: [int], offset: int): int

fn read_u32_le(data: [int], offset: int): int

fn parse_file_header(data: [int]): BmpFileHeader

fn parse_info_header(data: [int]): BmpInfoHeader

fn parse_palette(data: [int], offset: int, num_colors: int): [core.Color]

fn string_to_bytes(s: string): [int]

fn load_bmp(filepath: string): result.Result[image.Image, error.Error]

fn load_bmp_bytes(data: [int]): result.Result[image.Image, error.Error]

fn encode_bmp_bytes(img: image.Image): [int]

fn save_bmp(filepath: string, img: image.Image): bool


Procedures

proc write_u8(buf: [int], offset: int, value: int)

proc write_u16_le(buf: [int], offset: int, value: int)

proc write_u32_le(buf: [int], offset: int, value: int)


Generated by reefc doc