@std/image/bmp.ms#
Import each required symbol with import Name from "@std/image/bmp.ms".
decode_bmp Function#
Decodes an uncompressed BMP, or a 32-bit BMP with bit-field masks, into a raster of 3
channels (RGB) or 4 (RGBA, for 32-bit pixels with alpha). Palette images expand to
RGB. Malformed data returns EBADMSG, an unsupported feature such as RLE compression
returns ENOTSUP, and dimensions past max_pixels or the hard ceiling return
EOVERFLOW.
Manuscript
fn decode_bmp(data Bytes, max_pixels Int? = null) Result[Raster, Error] { ... }encode_bmp Function#
Encodes pixels as a 24-bit BMP, or as a 32-bit BMP when channels is 2 or 4 (alpha).
Gray pixels are stored as RGB. A size past the BMP limits (2^31 - 1 per dimension, or
4 GiB in total) returns EOVERFLOW.
Manuscript
fn encode_bmp(width Int, height Int, channels Int, pixels List[UInt8]) Result[Bytes, Error] { ... }