[][src]Struct image::ImageBuffer

pub struct ImageBuffer<P: Pixel, Container> { /* fields omitted */ }

Generic image buffer

Methods

impl<P, Container> ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]>, 
[src]

pub fn from_raw(
    width: u32,
    height: u32,
    buf: Container
) -> Option<ImageBuffer<P, Container>>
[src]

Contructs a buffer from a generic container (for example a Vec or a slice)

Returns None if the container is not big enough

pub fn into_raw(self) -> Container[src]

Returns the underlying raw buffer

pub fn dimensions(&self) -> (u32, u32)[src]

The width and height of this image.

pub fn width(&self) -> u32[src]

The width of this image.

pub fn height(&self) -> u32[src]

The height of this image.

pub fn pixels(&self) -> Pixels<P>[src]

Returns an iterator over the pixels of this image.

pub fn enumerate_pixels(&self) -> EnumeratePixels<P>[src]

Enumerates over the pixels of the image. The iterator yields the coordinates of each pixel along with a reference to them.

pub fn get_pixel(&self, x: u32, y: u32) -> &P[src]

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::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]> + DerefMut
[src]

pub fn pixels_mut(&mut self) -> PixelsMut<P>[src]

Returns an iterator over the mutable pixels of this image.

pub fn enumerate_pixels_mut(&mut self) -> EnumeratePixelsMut<P>[src]

Enumerates over the pixels of the image. The iterator yields the coordinates of each pixel along with a mutable reference to them.

pub fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut P[src]

Gets a reference to the mutable pixel at location (x, y)

Panics

Panics if (x, y) is out of the bounds (width, height).

pub fn put_pixel(&mut self, x: u32, y: u32, pixel: P)[src]

Puts a 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<Subpixel = u8> + 'static,
    Container: Deref<Target = [u8]>, 
[src]

pub fn save<Q>(&self, path: Q) -> Result<()> where
    Q: AsRef<Path>, 
[src]

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::Subpixel>> where
    P::Subpixel: 'static, 
[src]

pub fn new(width: u32, height: u32) -> ImageBuffer<P, Vec<P::Subpixel>>[src]

Creates a new image buffer based on a Vec<P::Subpixel>.

pub fn from_pixel(
    width: u32,
    height: u32,
    pixel: P
) -> ImageBuffer<P, Vec<P::Subpixel>>
[src]

Constructs a new ImageBuffer by copying a pixel

pub fn from_fn<F>(
    width: u32,
    height: u32,
    f: F
) -> ImageBuffer<P, Vec<P::Subpixel>> where
    F: FnMut(u32, u32) -> P, 
[src]

Constructs a new ImageBuffer by repeated application of the supplied function. The arguments to the function are the pixel's x and y coordinates.

pub fn from_vec(
    width: u32,
    height: u32,
    buf: Vec<P::Subpixel>
) -> Option<ImageBuffer<P, Vec<P::Subpixel>>>
[src]

Creates an image buffer out of an existing buffer. Returns None if the buffer is not big enough.

pub fn into_vec(self) -> Vec<P::Subpixel>[src]

Consumes the image buffer and returns the underlying data as an owned buffer

Trait Implementations

impl<P, Container> GenericImage for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    Container: Deref<Target = [P::Subpixel]> + DerefMut,
    P::Subpixel: 'static, 
[src]

type Pixel = P

The type of pixel.

unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> P[src]

Returns the pixel located at (x, y), ignoring bounds checking.

unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: P)[src]

Puts a pixel at location (x, y), ignoring bounds checking.

fn blend_pixel(&mut self, x: u32, y: u32, p: P)[src]

Put a pixel at location (x, y), taking into account alpha channels

DEPRECATED: This method will be removed. Blend the pixel directly instead.

impl<'a, 'b, Container, FromType: Pixel + 'static, ToType: Pixel + 'static> ConvertBuffer<ImageBuffer<ToType, Vec<<ToType as Pixel>::Subpixel>>> for ImageBuffer<FromType, Container> where
    Container: Deref<Target = [FromType::Subpixel]>,
    ToType: FromColor<FromType>,
    FromType::Subpixel: 'static,
    ToType::Subpixel: 'static, 
[src]

impl<P, Container> Clone for ImageBuffer<P, Container> where
    P: Pixel,
    Container: Deref<Target = [P::Subpixel]> + Clone
[src]

impl<P: Debug + Pixel, Container: Debug> Debug for ImageBuffer<P, Container>[src]

impl<P, Container> Deref for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]>, 
[src]

type Target = [P::Subpixel]

The resulting type after dereferencing.

impl<P, Container> DerefMut for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]> + DerefMut
[src]

impl<P, Container> Index<(u32, u32)> for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]>, 
[src]

type Output = P

The returned type after indexing.

impl<P, Container> IndexMut<(u32, u32)> for ImageBuffer<P, Container> where
    P: Pixel + 'static,
    P::Subpixel: 'static,
    Container: Deref<Target = [P::Subpixel]> + DerefMut
[src]

Auto Trait Implementations

impl<P, Container> Send for ImageBuffer<P, Container> where
    Container: Send,
    P: Send

impl<P, Container> Sync for ImageBuffer<P, Container> where
    Container: Sync,
    P: Sync

impl<P, Container> Unpin for ImageBuffer<P, Container> where
    Container: Unpin,
    P: Unpin

impl<P, Container> UnwindSafe for ImageBuffer<P, Container> where
    Container: UnwindSafe,
    P: UnwindSafe

impl<P, Container> RefUnwindSafe for ImageBuffer<P, Container> where
    Container: RefUnwindSafe,
    P: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> SetParameter for T[src]