pub struct RgbaSlice<'a> { /* private fields */ }Expand description
Wraps &[[u8; 4]] (contiguous sRGBA pixels) with width and height.
Implementations§
Source§impl<'a> RgbaSlice<'a>
impl<'a> RgbaSlice<'a>
Sourcepub fn try_new(
data: &'a [[u8; 4]],
width: usize,
height: usize,
) -> Result<Self, ZensimError>
pub fn try_new( data: &'a [[u8; 4]], width: usize, height: usize, ) -> Result<Self, ZensimError>
Create a new RgbaSlice from contiguous [R,G,B,A] pixels.
Defaults to AlphaMode::Straight. Use try_with_alpha_mode
or with_alpha_mode for explicit control.
Returns ZensimError::InvalidDataLength if data.len() < width * height.
Sourcepub fn new(data: &'a [[u8; 4]], width: usize, height: usize) -> Self
pub fn new(data: &'a [[u8; 4]], width: usize, height: usize) -> Self
Create a new RgbaSlice from contiguous [R,G,B,A] pixels.
Defaults to AlphaMode::Straight. Use with_alpha_mode
for explicit control.
§Panics
Panics if data.len() < width * height.
Sourcepub fn try_with_alpha_mode(
data: &'a [[u8; 4]],
width: usize,
height: usize,
alpha_mode: AlphaMode,
) -> Result<Self, ZensimError>
pub fn try_with_alpha_mode( data: &'a [[u8; 4]], width: usize, height: usize, alpha_mode: AlphaMode, ) -> Result<Self, ZensimError>
Create a new RgbaSlice with an explicit alpha mode.
Returns ZensimError::InvalidDataLength if data.len() < width * height.
Trait Implementations§
Source§impl ImageSource for RgbaSlice<'_>
impl ImageSource for RgbaSlice<'_>
Source§fn pixel_format(&self) -> PixelFormat
fn pixel_format(&self) -> PixelFormat
Pixel format (layout, bit depth, transfer function).
Source§fn alpha_mode(&self) -> AlphaMode
fn alpha_mode(&self) -> AlphaMode
Alpha channel interpretation.
Source§fn row_bytes(&self, y: usize) -> &[u8] ⓘ
fn row_bytes(&self, y: usize) -> &[u8] ⓘ
Raw bytes for row
y. Length must be at least width() * pixel_format().bytes_per_pixel().Source§fn color_primaries(&self) -> ColorPrimaries
fn color_primaries(&self) -> ColorPrimaries
Color primaries (gamut) of the image data. Read more
impl<'a> Copy for RgbaSlice<'a>
Auto Trait Implementations§
impl<'a> Freeze for RgbaSlice<'a>
impl<'a> RefUnwindSafe for RgbaSlice<'a>
impl<'a> Send for RgbaSlice<'a>
impl<'a> Sync for RgbaSlice<'a>
impl<'a> Unpin for RgbaSlice<'a>
impl<'a> UnsafeUnpin for RgbaSlice<'a>
impl<'a> UnwindSafe for RgbaSlice<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more