Struct image::ImageBuffer
[-] [+]
[src]
pub struct ImageBuffer<P: Pixel, Container> { // some fields omitted }
Generic image buffer
Methods
impl<P: Pixel + 'static, Container: ArrayLike<Subpixel>> ImageBuffer<P, Container> where Subpixel: 'static
fn from_raw(width: u32, height: u32, buf: Container) -> Option<ImageBuffer<P, Container>>
Contructs a buffer from a generic container
(for example a Vec
or a slice)
Returns None if the container is not big enough
fn into_raw(self) -> Container
Returns the underlying raw buffer
fn dimensions(&self) -> (u32, u32)
The width and height of this image.
fn width(&self) -> u32
The width of this image.
fn height(&self) -> u32
The height of this image.
fn as_slice(&self) -> &[Subpixel]
The raw image data as a slice.
fn as_mut_slice(&mut self) -> &mut [Subpixel]
The raw image data as a slice.
fn pixels<'a>(&'a self) -> Pixels<'a, P>
Returns an iterator over the pixels of this image.
fn pixels_mut(&mut self) -> PixelsMut<P>
Returns an iterator over the mutable pixels of this image. The iterator yields the coordinates of each pixel along with a mutable reference to them.
fn enumerate_pixels<'a>(&'a self) -> EnumeratePixels<'a, P>
Enumerates over the pixels of the image. The iterator yields the coordinates of each pixel along with a reference to them.
fn enumerate_pixels_mut<'a>(&'a mut self) -> EnumeratePixelsMut<'a, P>
Enumerates over the pixels of the image.
fn get_pixel(&self, x: u32, y: u32) -> &P
Gets a reference to the pixel at location (x, y)
Panics
Panics if (x, y)
is out of the bounds (width, height)
.
fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
Gets a reference to the mutable pixel at location (x, y)
Panics
Panics if (x, y)
is out of the bounds (width, height)
.
fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
impl<P: Pixel<Subpixel=u8> + 'static, Container: ArrayLike<u8>> ImageBuffer<P, Container>
fn save(&self, path: &Path) -> IoResult<()>
Saves the buffer to a file at the path specified.
The image format is derived from the file extension. Currently only jpeg and png files are supported.
impl<P: Pixel + 'static> ImageBuffer<P, Vec<Subpixel>> where Subpixel: 'static
fn new(width: u32, height: u32) -> ImageBuffer<P, Vec<Subpixel>>
Creates a new image buffer based on a Vec<P::Subpixel>
.
fn from_pixel(width: u32, height: u32, pixel: P) -> ImageBuffer<P, Vec<Subpixel>>
Constructs a new ImageBuffer by copying a pixel
fn from_fn<F>(width: u32, height: u32, f: F) -> ImageBuffer<P, Vec<Subpixel>> where F: Fn(u32, u32) -> P
Constructs a new ImageBuffer by repeated application of the supplied function. The arguments to the function are the pixel's x and y coordinates.
fn from_vec(width: u32, height: u32, buf: Vec<Subpixel>) -> Option<ImageBuffer<P, Vec<Subpixel>>>
Creates an image buffer out of an existing buffer. Returns None if the buffer is not big enough.
fn into_vec(self) -> Vec<Subpixel>
Consumes the image buffer and returns the underlying data as an owned buffer
Trait Implementations
impl<P: Pixel, Container: ArrayLike<Subpixel> + Clone> Clone for ImageBuffer<P, Container>
fn clone(&self) -> ImageBuffer<P, Container>
fn clone_from(&mut self, source: &Self)
impl<P: Pixel + 'static, Container: ArrayLike<Subpixel>> GenericImage for ImageBuffer<P, Container> where Subpixel: 'static
type Pixel = P
fn dimensions(&self) -> (u32, u32)
fn bounds(&self) -> (u32, u32, u32, u32)
fn get_pixel(&self, x: u32, y: u32) -> P
fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P
fn put_pixel(&mut self, x: u32, y: u32, pixel: P)
fn blend_pixel(&mut self, x: u32, y: u32, p: P)
Put a pixel at location (x, y), taking into account alpha channels