Crate image_buffer

Source
Expand description

Image buffer abstractions

§Image buffer

image_buffer provides an ImageBuffer which helps to access the pixels of an image. It provides iterators over the pixels of the image (via ImageBuffer::pixels[_mut] and ImageBuffer::enumerate_pixels[_mut]). Furthermore it implements Index and IndexMut which takes a tuple (x, y) with the coordinates of the pixel. (0, 0) is in the top left corner.

An image buffer can either be create by wrapping an existing buffer

let mut data = vec![0; 100 * 100];
let buffer: GrayImage = ImageBuffer::from_raw(100, 100, data).unwrap();
data = buffer.into_raw();

or by constructing a new one baked by a std::Vec

let _: RgbImage = ImageBuffer::new(100, 100);

.

§Color types

This crate implements various color types, accessible via the color module. They implement From wherever it makes sense to be able to convert between them. The Rgb to Gray conversion assumes Rgb to be in the sRGB color model.

The ImageBuffer uses this to provide a convenience method for color conversions

let _: GrayImage = RgbImage::new(100, 100).convert_buffer();

Modules§

Structs§

Traits§

Type Aliases§