pub struct ImageRef<'a, P: Pixel> { /* private fields */ }Expand description
A borrowed, length-validated view of an interleaved image of pixel type P.
Cheap to copy (a slice + Dimensions + a zero-sized marker). Construct one at an API boundary
with ImageRef::new; pass it to an crate::EncodeImage implementation.
Implementations§
Source§impl<'a, P: Pixel> ImageRef<'a, P>
impl<'a, P: Pixel> ImageRef<'a, P>
Sourcepub fn new(data: &'a [P::Sample], dims: Dimensions) -> Result<Self>
pub fn new(data: &'a [P::Sample], dims: Dimensions) -> Result<Self>
Brands data as an image of dims, validating that its length is exactly
width * height * P::CHANNELS.
§Errors
Returns Error::InvalidInput if dims is zero-sized, if width * height * channels
overflows usize, or if data.len() does not equal that product.
Sourcepub fn dimensions(self) -> Dimensions
pub fn dimensions(self) -> Dimensions
The image dimensions.
Sourcepub fn as_samples(self) -> &'a [P::Sample]
pub fn as_samples(self) -> &'a [P::Sample]
The raw interleaved samples (width * height * P::CHANNELS of them, row-major). The
zero-cost escape hatch a codec uses to feed its existing slice-based hot path.
Sourcepub fn rows(self) -> impl ExactSizeIterator<Item = &'a [P::Sample]>
pub fn rows(self) -> impl ExactSizeIterator<Item = &'a [P::Sample]>
Iterates the rows top to bottom, each a width * P::CHANNELS-sample slice.
Trait Implementations§
impl<'a, P: Copy + Pixel> Copy for ImageRef<'a, P>
Auto Trait Implementations§
impl<'a, P> Freeze for ImageRef<'a, P>
impl<'a, P> RefUnwindSafe for ImageRef<'a, P>
impl<'a, P> Send for ImageRef<'a, P>
impl<'a, P> Sync for ImageRef<'a, P>
impl<'a, P> Unpin for ImageRef<'a, P>where
P: Unpin,
impl<'a, P> UnsafeUnpin for ImageRef<'a, P>
impl<'a, P> UnwindSafe for ImageRef<'a, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more