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

BmpResult

Fields:

Name Type
ok bool
img image.Image
error_msg string

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 bmp_result_ok(result: BmpResult): bool

fn bmp_result_image(result: BmpResult): image.Image

fn bmp_result_error(result: BmpResult): string

fn make_bmp_error(msg: string): BmpResult

fn make_bmp_ok(img: image.Image): BmpResult

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): BmpResult

fn load_bmp_bytes(data: [int]): BmpResult

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