bmp 0.0.5

Small library for reading and writing BMP images in Rust
docs.rs failed to build bmp-0.0.5
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: bmp-0.5.0

rust-bmp

Build Status

Small module for reading and writing bitmap images. Currently only 24-bit RGB BMP images are supported.

Usage

Initialize a new image with the new function, specifying width and height.

extern crate bmp;
use bmp::Image;

let mut img = Image::new(100, 100);

Edit image data using the get_pixel and set_pixel functions. Save an image with the save function, specifying the path.

let pixel = img.get_pixel(0, 0);
img.set_pixel(50, 50, Pixel{r: 255, g: 255, b: 255});
img.save("path/to/img.bmp");

Open an existing image with the open function, specifying the path.

let mut img = Image::open("path/to/img.bmp");

Example

extern crate bmp;

use bmp::Image;

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

    for (x, y) in img.coordinates() {
        img.set_pixel(x, y, bmp::Pixel {
            r: (x - y / 255) as u8,
            g: (y - x / 255) as u8,
            b: (x + y / 255) as u8
        })
    }
    img.save("img.bmp");
}