[][src]Struct ffimage::packed::generic::ImageBuffer

pub struct ImageBuffer<T: Pixel> { /* fields omitted */ }

Implementations

impl<T: Pixel> ImageBuffer<T>[src]

pub fn new(width: u32, height: u32) -> Self[src]

Returns an image buffer with pixel accessors

The backing memory is allocated by this struct. There is no padding added so only the minimum amount of memory is consumed. In contrast to flat image buffers, fat buffer structs own their data and can safely be moved between threads.

Arguments

  • width - Width in pixels
  • height - Height in pixels

Example

use ffimage::color::rgb::*;
use ffimage::core::GenericImage;
use ffimage::packed::generic::ImageBuffer;

let mut buf = ImageBuffer::<Rgb<u8>>::new(3, 3);
let pix = Rgb::<u8>::new([255, 255, 255]);
buf.set_pixel(0, 0, &pix).unwrap();

pub fn from_raw(width: u32, height: u32, raw: Vec<T::T>) -> Option<Self>[src]

Returns an image buffer with pixel accessors

The pixel memory is copied into an allocated buffer owned by this struct.

Arguments

  • width - Width in pixels
  • height - Height in pixels
  • raw - Pixel memory storage owned by the instance

Example

use ffimage::color::rgb::*;
use ffimage::core::GenericImage;
use ffimage::packed::generic::ImageBuffer;

let mut mem = vec![0; 3];
let mut buf = ImageBuffer::<Rgb<u8>>::from_raw(1, 1, mem)
    .expect("Memory region too small");
let pix = Rgb::<u8>::new([255, 255, 255]);
buf.set_pixel(0, 0, &pix).unwrap();

pub fn raw(&self) -> &[T::T][src]

pub fn raw_mut(&mut self) -> &mut [T::T][src]

pub fn stride(&self) -> usize[src]

Returns the length of one pixel row in bytes

Trait Implementations

impl<'a, T: Pixel, '_> From<&'_ ImageView<'a, T>> for ImageBuffer<T>[src]

impl<'a, T: Pixel, '_> From<&'_ ImageViewMut<'a, T>> for ImageBuffer<T>[src]

impl<'a, T: Pixel + 'a> GenericImage<'a> for ImageBuffer<T>[src]

impl<'a, T: Pixel + 'a> GenericImageView<'a> for ImageBuffer<T>[src]

type T = T

Pixel type

type SubImage = SubImageView<'a, Self>

Type of sub images

impl<T: Pixel> Index<usize> for ImageBuffer<T>[src]

type Output = [T]

The returned type after indexing.

impl<T: Pixel> IndexMut<usize> for ImageBuffer<T>[src]

impl<T: Pixel> Into<Vec<<T as Pixel>::T>> for ImageBuffer<T>[src]

impl<'a, T: Pixel> IntoIterator for &'a ImageBuffer<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = PixelIter<'a, ImageBuffer<T>>

Which kind of iterator are we turning this into?

impl<'a, T: Pixel> IntoIterator for &'a mut ImageBuffer<T>[src]

type Item = &'a mut T

The type of the elements being iterated over.

type IntoIter = PixelIterMut<'a, ImageBuffer<T>>

Which kind of iterator are we turning this into?

impl<'a, SP, DP> TryConvert<ImageBuffer<DP>> for ImageView<'a, SP> where
    SP: Pixel,
    DP: Pixel,
    SP: TryConvertSlice<DP>, 
[src]

type Error = ()

impl<'a, SP, DP> TryConvert<ImageBuffer<DP>> for ImageViewMut<'a, SP> where
    SP: Pixel,
    DP: Pixel,
    SP: TryConvertSlice<DP>, 
[src]

type Error = ()

impl<SP, DP> TryConvert<ImageBuffer<DP>> for ImageBuffer<SP> where
    SP: Pixel,
    DP: Pixel,
    SP: TryConvertSlice<DP>, 
[src]

type Error = ()

impl<'b, SP, DP> TryConvert<ImageViewMut<'b, DP>> for ImageBuffer<SP> where
    SP: Pixel,
    DP: Pixel,
    SP: TryConvertSlice<DP>, 
[src]

type Error = ()

Auto Trait Implementations

impl<T> RefUnwindSafe for ImageBuffer<T> where
    <T as Pixel>::T: RefUnwindSafe

impl<T> Send for ImageBuffer<T> where
    <T as Pixel>::T: Send

impl<T> Sync for ImageBuffer<T> where
    <T as Pixel>::T: Sync

impl<T> Unpin for ImageBuffer<T> where
    <T as Pixel>::T: Unpin

impl<T> UnwindSafe for ImageBuffer<T> where
    <T as Pixel>::T: UnwindSafe

Blanket Implementations

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

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

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

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

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

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.