#[non_exhaustive]pub struct PixelSliceMut<'a, P = ()> { /* private fields */ }Expand description
Mutable borrowed view of pixel data.
Same semantics as PixelSlice but allows writing to rows.
The type parameter P tracks pixel format at compile time.
Implementations§
Source§impl<'a> PixelSliceMut<'a>
impl<'a> PixelSliceMut<'a>
Sourcepub fn new(
data: &'a mut [u8],
width: u32,
rows: u32,
stride_bytes: usize,
descriptor: PixelDescriptor,
) -> Result<PixelSliceMut<'a>, BufferError>
pub fn new( data: &'a mut [u8], width: u32, rows: u32, stride_bytes: usize, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'a>, BufferError>
Create a new mutable pixel slice with validation.
stride_bytes is the byte distance between the start of consecutive rows.
§Errors
Returns an error if the data is too small, the stride is too small, or the data is not aligned for the channel type.
Source§impl<'a, P> PixelSliceMut<'a, P>
impl<'a, P> PixelSliceMut<'a, P>
Sourcepub fn erase(self) -> PixelSliceMut<'a>
pub fn erase(self) -> PixelSliceMut<'a>
Erase the pixel type, returning a type-erased mutable slice.
Sourcepub fn try_typed<Q>(self) -> Option<PixelSliceMut<'a, Q>>where
Q: Pixel,
pub fn try_typed<Q>(self) -> Option<PixelSliceMut<'a, Q>>where
Q: Pixel,
Try to reinterpret as a typed mutable pixel slice.
Succeeds if the descriptors are layout-compatible.
Sourcepub fn with_descriptor(
self,
descriptor: PixelDescriptor,
) -> PixelSliceMut<'a, P>
pub fn with_descriptor( self, descriptor: PixelDescriptor, ) -> PixelSliceMut<'a, P>
Replace the descriptor with a layout-compatible one.
See PixelSlice::with_descriptor() for details.
Sourcepub fn reinterpret(
self,
descriptor: PixelDescriptor,
) -> Result<PixelSliceMut<'a, P>, BufferError>
pub fn reinterpret( self, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'a, P>, BufferError>
Reinterpret the buffer with a different physical layout.
See PixelSlice::reinterpret() for details.
Sourcepub fn with_transfer(self, tf: TransferFunction) -> PixelSliceMut<'a, P>
pub fn with_transfer(self, tf: TransferFunction) -> PixelSliceMut<'a, P>
Return a copy with a different transfer function.
Sourcepub fn with_primaries(self, cp: ColorPrimaries) -> PixelSliceMut<'a, P>
pub fn with_primaries(self, cp: ColorPrimaries) -> PixelSliceMut<'a, P>
Return a copy with different color primaries.
Sourcepub fn with_signal_range(self, sr: SignalRange) -> PixelSliceMut<'a, P>
pub fn with_signal_range(self, sr: SignalRange) -> PixelSliceMut<'a, P>
Return a copy with a different signal range.
Sourcepub fn with_alpha_mode(self, am: Option<AlphaMode>) -> PixelSliceMut<'a, P>
pub fn with_alpha_mode(self, am: Option<AlphaMode>) -> PixelSliceMut<'a, P>
Return a copy with a different alpha mode.
Sourcepub fn descriptor(&self) -> PixelDescriptor
pub fn descriptor(&self) -> PixelDescriptor
Pixel format descriptor.
Sourcepub fn color_context(&self) -> Option<&Arc<ColorContext>>
pub fn color_context(&self) -> Option<&Arc<ColorContext>>
Source color context (ICC/CICP metadata), if set.
Sourcepub fn with_color_context(self, ctx: Arc<ColorContext>) -> PixelSliceMut<'a, P>
pub fn with_color_context(self, ctx: Arc<ColorContext>) -> PixelSliceMut<'a, P>
Return a copy of this slice with a color context attached.
Sourcepub fn sub_rows_mut(&mut self, y: u32, count: u32) -> PixelSliceMut<'_, P>
pub fn sub_rows_mut(&mut self, y: u32, count: u32) -> PixelSliceMut<'_, P>
Source§impl<'a, P> PixelSliceMut<'a, P>where
P: Pixel,
impl<'a, P> PixelSliceMut<'a, P>where
P: Pixel,
Sourcepub fn new_typed(
data: &'a mut [u8],
width: u32,
rows: u32,
stride_pixels: u32,
) -> Result<PixelSliceMut<'a, P>, BufferError>
pub fn new_typed( data: &'a mut [u8], width: u32, rows: u32, stride_pixels: u32, ) -> Result<PixelSliceMut<'a, P>, BufferError>
Create a typed mutable pixel slice.
stride_pixels is the number of pixels per row (>= width).
The byte stride is stride_pixels * size_of::<P>().
Source§impl<'a> PixelSliceMut<'a, Rgbx>
impl<'a> PixelSliceMut<'a, Rgbx>
Sourcepub fn swap_to_bgrx(self) -> PixelSliceMut<'a, Bgrx>
pub fn swap_to_bgrx(self) -> PixelSliceMut<'a, Bgrx>
Byte-swap R<->B channels in place, converting to BGRX.
Source§impl<'a> PixelSliceMut<'a, Bgrx>
impl<'a> PixelSliceMut<'a, Bgrx>
Sourcepub fn swap_to_rgbx(self) -> PixelSliceMut<'a, Rgbx>
pub fn swap_to_rgbx(self) -> PixelSliceMut<'a, Rgbx>
Byte-swap B<->R channels in place, converting to RGBX.