Trait img::Image [] [src]

pub trait Image: Clone {
    type PixelT: Pixel;
    fn width(&self) -> u32;
    fn height(&self) -> u32;
    fn pitch(&self) -> u32;
    fn get_pixel(&self, x: u32, y: u32) -> Option<Self::PixelT>;
    fn set_pixel(&mut self, x: u32, y: u32, value: Self::PixelT);
    fn get_size_in_bytes(&self) -> usize;
    fn load_from_raw_buffer(&mut self, buffer: &[u8]);
    fn write_into_raw_buffer(&self, buffer: &mut [u8]);
}

Trait which defines the minimum requirements for an image implementation.

It is important to note, that usually you want to use ImageVal instead of directly use this trait. Use this trait directly if you want to describe a type bound. This is for example necessary if you want to define a type with a parameter, which has to be an Image. To store actual values use ImageVal.

Examples

use img::{Image, ImageVal};
struct Foo<T: Image> {
    data: ImageVal<T>,
};

Associated Types

The Pixel type of this image.

With this information we can statically enforce, that an image is only used with the correct pixel layout.

Required Methods

Returns the width of the image in pixels.

Returns the height of the image in pixels.

Returns the pitch of the image in bytes.

Retrieve the pixel for a given location (x, y).

If an location is accessed which is out of bound, the result will be None.

Stores a pixel at a location (x, y) in the Image.

Panics

If the location is out of bounds, this function will panic.

Returns the memory size for the whole image in bytes.

Loads an Image out of a raw buffer.

This is important for input output functionality.

Writes an Image into a raw buffer.

This is important for input output functionality.

Implementors