Crate bmp

Source
Expand description

A small library for reading and writing BMP images.

The library supports uncompressed BMP Version 3 images. The different decoding and encoding schemes is shown in the table below.

SchemeDecodingEncodingCompression
24 bppNo
8 bppNo
4 bppNo
1 bppNo

§Example

#[macro_use]
extern crate bmp;
use bmp::{Image, Pixel};

fn main() {
    let mut img = Image::new(256, 256);

    for (x, y) in img.coordinates() {
        img.set_pixel(x, y, px!(x, y, 200));
    }
    let _ = img.save("img.bmp");
}

Modules§

consts
Common color constants accessible by names.

Macros§

px
Macro to generate a Pixel from r, g and b values.

Structs§

BmpError
The error type returned if the decoding of an image from disk fails.
Image
The image type provided by the library.
ImageIndex
An Iterator returning the x and y coordinates of an image.
Pixel
The pixel data used in the Image.

Enums§

BmpErrorKind
The different kinds of possible BMP errors.

Functions§

from_reader
Attempts to construct a new Image from the given reader. Returns a BmpResult, either containing an Image or a BmpError.
open
Utility function to load an Image from the file specified by path. It uses the from_reader function internally to decode the Image. Returns a BmpResult, either containing an Image or a BmpError.

Type Aliases§

BmpResult
A result type, either containing an Image or a BmpError.