[−][src]Struct ffimage::packed::image::generic::GenericBuffer
Implementations
impl<T: Pixel> GenericBuffer<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 pixelsheight
- Height in pixels
Example
use ffimage::color::rgb::*; use ffimage::core::ImageBuffer; use ffimage::packed::GenericImageBuffer; let mut buf = GenericImageBuffer::<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 pixelsheight
- Height in pixelsraw
- Pixel memory storage owned by the instance
Example
use ffimage::color::rgb::*; use ffimage::core::ImageBuffer; use ffimage::packed::GenericImageBuffer; let mut mem = vec![0; 3]; let mut buf = GenericImageBuffer::<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]
Trait Implementations
impl<T: Pixel> AccessPixel for GenericBuffer<T>
[src]
type PixelType = T
fn pixel_row(&self, y: u32) -> Option<&[Self::PixelType]>
[src]
fn pixel(&self, x: u32, y: u32) -> Option<&Self::PixelType>
[src]
impl<T: Pixel> AccessPixelMut for GenericBuffer<T>
[src]
type PixelType = T
fn pixel_row_mut(&mut self, y: u32) -> Option<&mut [Self::PixelType]>
[src]
fn pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::PixelType>
[src]
impl<'a, '_, T: Pixel> From<&'_ GenericFlatBuffer<'a, T>> for GenericBuffer<T>
[src]
fn from(view: &GenericFlatBuffer<'a, T>) -> Self
[src]
impl<'a, '_, T: Pixel> From<&'_ GenericView<'a, T>> for GenericBuffer<T>
[src]
fn from(view: &GenericView<'a, T>) -> Self
[src]
impl<T: Pixel> ImageBuffer for GenericBuffer<T>
[src]
impl<T: Pixel> ImageView for GenericBuffer<T>
[src]
type T = T
Pixel type
fn width(&self) -> u32
[src]
fn height(&self) -> u32
[src]
fn stride(&self) -> usize
[src]
fn get_pixel(&self, x: u32, y: u32) -> Option<Self::T>
[src]
impl<T: Pixel> Into<Vec<<T as Pixel>::T>> for GenericBuffer<T>
[src]
impl<'a, T: Pixel> IntoIterator for &'a GenericBuffer<T>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = PixelIter<'a, GenericBuffer<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, T: Pixel> IntoIterator for &'a mut GenericBuffer<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = PixelIterMut<'a, GenericBuffer<T>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, SP, DP> TryConvert<GenericBuffer<DP>> for GenericView<'a, SP> where
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
[src]
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
type Error = ()
fn try_convert(&self, output: &mut GenericBuffer<DP>) -> Result<(), Self::Error>
[src]
impl<'a, SP, DP> TryConvert<GenericBuffer<DP>> for GenericFlatBuffer<'a, SP> where
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
[src]
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
type Error = ()
fn try_convert(&self, output: &mut GenericBuffer<DP>) -> Result<(), Self::Error>
[src]
impl<SP, DP> TryConvert<GenericBuffer<DP>> for GenericBuffer<SP> where
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
[src]
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
type Error = ()
fn try_convert(&self, output: &mut GenericBuffer<DP>) -> Result<(), Self::Error>
[src]
impl<'b, SP, DP> TryConvert<GenericFlatBuffer<'b, DP>> for GenericBuffer<SP> where
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
[src]
SP: Pixel,
DP: Pixel,
SP: TryConvertSlice<DP>,
type Error = ()
fn try_convert(
&self,
output: &mut GenericFlatBuffer<'b, DP>
) -> Result<(), Self::Error>
[src]
&self,
output: &mut GenericFlatBuffer<'b, DP>
) -> Result<(), Self::Error>
Auto Trait Implementations
impl<T> RefUnwindSafe for GenericBuffer<T> where
<T as Pixel>::T: RefUnwindSafe,
<T as Pixel>::T: RefUnwindSafe,
impl<T> Send for GenericBuffer<T> where
<T as Pixel>::T: Send,
<T as Pixel>::T: Send,
impl<T> Sync for GenericBuffer<T> where
<T as Pixel>::T: Sync,
<T as Pixel>::T: Sync,
impl<T> Unpin for GenericBuffer<T> where
<T as Pixel>::T: Unpin,
<T as Pixel>::T: Unpin,
impl<T> UnwindSafe for GenericBuffer<T> where
<T as Pixel>::T: UnwindSafe,
<T as Pixel>::T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,