Struct image::ImageBuffer
[-] [+]
[src]
pub struct ImageBuffer<P: Pixel, Container> { // some fields omitted }
Generic image buffer
Methods
impl<P, Container> ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]>
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 pixels<'a>(&'a self) -> Pixels<'a, P>
Returns an iterator over the pixels of this image.
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 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)
.
impl<P, Container> ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]> + DerefMut
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_mut<'a>(&'a mut self) -> EnumeratePixelsMut<'a, P>
Enumerates over the pixels of the image.
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, Container> ImageBuffer<P, Container> where P: Pixel<Subpixel=u8> + 'static, Container: Deref<Target=[u8]>
fn save<Q>(&self, path: Q) -> Result<()> where Q: AsRef<Path>
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<P>> where P: 'static
fn new(width: u32, height: u32) -> ImageBuffer<P, Vec<P>>
Creates a new image buffer based on a Vec<P::Subpixel>
.
fn from_pixel(width: u32, height: u32, pixel: P) -> ImageBuffer<P, Vec<P>>
Constructs a new ImageBuffer by copying a pixel
fn from_fn<F>(width: u32, height: u32, f: F) -> ImageBuffer<P, Vec<P>> 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<P>) -> Option<ImageBuffer<P, Vec<P>>>
Creates an image buffer out of an existing buffer. Returns None if the buffer is not big enough.
fn into_vec(self) -> Vec<P>
Consumes the image buffer and returns the underlying data as an owned buffer
Trait Implementations
impl<P, Container> Deref for ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]>
type Target = [P]
fn deref<'a>(&'a self) -> &'a <ImageBuffer<P, Container> as Deref>::Target
impl<P, Container> DerefMut for ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]> + DerefMut
fn deref_mut<'a>(&'a mut self) -> &'a mut <ImageBuffer<P, Container> as Deref>::Target
impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]>
impl<P, Container> IndexMut<(u32, u32)> for ImageBuffer<P, Container> where P: Pixel + 'static, P: 'static, Container: Deref<Target=[P]> + DerefMut
impl<P, Container> Clone for ImageBuffer<P, Container> where P: Pixel, Container: Deref<Target=[P]> + Clone
fn clone(&self) -> ImageBuffer<P, Container>
fn clone_from(&mut self, source: &Self)
impl<P, Container> GenericImage for ImageBuffer<P, Container> where P: Pixel + 'static, Container: Deref<Target=[P]> + DerefMut, P: '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