#[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>, At<BufferError>>
pub fn new( data: &'a mut [u8], width: u32, rows: u32, stride_bytes: usize, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'a>, At<BufferError>>
Create a new mutable pixel slice with validation.
stride_bytes is the byte distance between the start of consecutive rows.
§Endianness contract
Multi-byte samples (U16, F16, F32) are interpreted in native byte
order; see PixelSlice::new — the same contract applies here.
§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>, At<BufferError>>
pub fn reinterpret( self, descriptor: PixelDescriptor, ) -> Result<PixelSliceMut<'a, P>, At<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 with_diffuse_white(self, white: DiffuseWhite) -> PixelSliceMut<'a, P>
pub fn with_diffuse_white(self, white: DiffuseWhite) -> PixelSliceMut<'a, P>
Relabel the source diffuse-white anchor — the cd/m² that relative-linear
1.0 represents. Reinterpretation only: pixels are untouched (use a
converter to change pixel values). Clones any existing ColorContext,
overrides its diffuse_white, and re-attaches it.
Sourcepub fn with_cicp(self, cicp: Cicp) -> PixelSliceMut<'a, P>
pub fn with_cicp(self, cicp: Cicp) -> PixelSliceMut<'a, P>
Relabel the source Cicp colour signalling. Reinterpretation only
— pixels are untouched. Clones any existing ColorContext, sets
cicp, and re-attaches it.
Sourcepub fn with_icc(self, icc: impl Into<Arc<[u8]>>) -> PixelSliceMut<'a, P>
pub fn with_icc(self, icc: impl Into<Arc<[u8]>>) -> PixelSliceMut<'a, P>
Relabel the source ICC profile. Reinterpretation only — pixels are
untouched. Clones any existing ColorContext, sets icc, and
re-attaches it.
Sourcepub fn as_pixel_slice(&self) -> PixelSlice<'_, P>
pub fn as_pixel_slice(&self) -> PixelSlice<'_, P>
Reborrow as an immutable PixelSlice (zero-copy).
The returned slice borrows from self, so the mutable slice
cannot be used while the immutable reborrow is alive.
Sourcepub fn as_strided_bytes(&self) -> &[u8] ⓘ
pub fn as_strided_bytes(&self) -> &[u8] ⓘ
Zero-copy access to the raw backing bytes, including any stride padding.
Unlike PixelSlice::as_strided_bytes() (which clips to the image
extent), this returns the full backing buffer so callers can write
stride padding (zeroing, codec requirements, etc.).
Sourcepub fn as_strided_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_strided_bytes_mut(&mut self) -> &mut [u8] ⓘ
Mutable access to the raw backing bytes, including any stride padding.
Returns the full backing buffer so callers can write stride padding.
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>, At<BufferError>>
pub fn new_typed( data: &'a mut [u8], width: u32, rows: u32, stride_pixels: u32, ) -> Result<PixelSliceMut<'a, P>, At<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, Rgbx>
impl<'a> PixelSliceMut<'a, Rgbx>
Sourcepub fn upgrade_to_rgba(self) -> PixelSliceMut<'a, Rgba<u8>>
pub fn upgrade_to_rgba(self) -> PixelSliceMut<'a, Rgba<u8>>
Upgrade to RGBA by setting all padding bytes to 255 (fully opaque).
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.
Source§impl<'a> PixelSliceMut<'a, Bgrx>
impl<'a> PixelSliceMut<'a, Bgrx>
Sourcepub fn upgrade_to_bgra(self) -> PixelSliceMut<'a, Bgra<u8>>
pub fn upgrade_to_bgra(self) -> PixelSliceMut<'a, Bgra<u8>>
Upgrade to BGRA by setting all padding bytes to 255 (fully opaque).
Source§impl<'a> PixelSliceMut<'a, Rgba<u8>>
impl<'a> PixelSliceMut<'a, Rgba<u8>>
Sourcepub fn matte_to_rgbx(self, bg: Rgb<u8>) -> PixelSliceMut<'a, Rgbx>
pub fn matte_to_rgbx(self, bg: Rgb<u8>) -> PixelSliceMut<'a, Rgbx>
Matte alpha against a solid RGB background, producing RGBX.
Each pixel is composited: out = src * alpha/255 + bg * (255 - alpha)/255.
The alpha byte becomes padding.
Sourcepub fn strip_alpha_to_rgbx(self) -> PixelSliceMut<'a, Rgbx>
pub fn strip_alpha_to_rgbx(self) -> PixelSliceMut<'a, Rgbx>
Strip alpha to RGBX without compositing (just mark as padding).
The alpha byte value is preserved in memory but semantically ignored. Use when you know alpha is already 255 or don’t care about the values.
Sourcepub fn swap_to_bgra(self) -> PixelSliceMut<'a, Bgra<u8>>
pub fn swap_to_bgra(self) -> PixelSliceMut<'a, Bgra<u8>>
Byte-swap R<->B channels in place, converting to BGRA.
Source§impl<'a> PixelSliceMut<'a, Bgra<u8>>
impl<'a> PixelSliceMut<'a, Bgra<u8>>
Sourcepub fn matte_to_bgrx(self, bg: Rgb<u8>) -> PixelSliceMut<'a, Bgrx>
pub fn matte_to_bgrx(self, bg: Rgb<u8>) -> PixelSliceMut<'a, Bgrx>
Matte alpha against a solid RGB background, producing BGRX.
Each pixel is composited: out = src * alpha/255 + bg * (255 - alpha)/255.
The alpha byte becomes padding.
Sourcepub fn strip_alpha_to_bgrx(self) -> PixelSliceMut<'a, Bgrx>
pub fn strip_alpha_to_bgrx(self) -> PixelSliceMut<'a, Bgrx>
Strip alpha to BGRX without compositing (just mark as padding).
Sourcepub fn swap_to_rgba(self) -> PixelSliceMut<'a, Rgba<u8>>
pub fn swap_to_rgba(self) -> PixelSliceMut<'a, Rgba<u8>>
Byte-swap B<->R channels in place, converting to RGBA.
Trait Implementations§
Source§impl<P> Debug for PixelSliceMut<'_, P>
impl<P> Debug for PixelSliceMut<'_, P>
Source§impl<'a, P> From<PixelSliceMut<'a, P>> for PixelSliceMut<'a>where
P: Pixel,
impl<'a, P> From<PixelSliceMut<'a, P>> for PixelSliceMut<'a>where
P: Pixel,
Source§fn from(typed: PixelSliceMut<'a, P>) -> PixelSliceMut<'a>
fn from(typed: PixelSliceMut<'a, P>) -> PixelSliceMut<'a>
Source§impl<'a, P> From<PixelSliceMut<'a, P>> for PixelSlice<'a, P>
Consume a mutable pixel slice and produce an immutable one (zero-copy).
impl<'a, P> From<PixelSliceMut<'a, P>> for PixelSlice<'a, P>
Consume a mutable pixel slice and produce an immutable one (zero-copy).