Skip to main content

PixelViewMut

Struct PixelViewMut 

Source
pub struct PixelViewMut<'a> { /* private fields */ }
Expand description

Zero-copy mutable view of an interleaved image or rectangular crop.

Implementations§

Source§

impl<'a> PixelViewMut<'a>

Source

pub fn new( data: &'a mut [u8], width: u32, height: u32, stride_bytes: usize, format: &'a PixelFormat, ) -> Result<PixelViewMut<'a>, At<BufferError>>

Borrow mutable strided bytes with checked dimensions, alignment, and length (zero heap allocation).

Pass &formats::RGB8_SRGB (or any crate::formats::* preset) or a borrowed &'a PixelFormat. If a view genuinely needs to own a dynamically constructed PixelFormat, use new_with_format_cow with FormatCow::from_owned or FormatCow::from_arc.

Source

pub fn new_with_format_cow( data: &'a mut [u8], width: u32, height: u32, stride_bytes: usize, format: FormatCow<'a>, ) -> Result<PixelViewMut<'a>, At<BufferError>>

Borrow mutable strided bytes with an explicit FormatCow<'a>.

Source

pub fn hdr(&self) -> HdrMetadata

Descriptive HDR container metadata attached to this mutable view.

Source

pub fn hdr_ref(&self) -> Option<&HdrMetadata>

Zero-copy reference to attached non-empty HDR metadata (None if empty/unset).

Source

pub fn with_hdr(self, hdr: HdrMetadata) -> PixelViewMut<'a>

Attach descriptive HDR metadata to this mutable view.

Source

pub fn with_hdr_ref(self, hdr: &'a HdrMetadata) -> PixelViewMut<'a>

Borrow descriptive HDR metadata onto this mutable view with zero heap allocation and zero atomic refcount overhead (ignores empty HdrMetadata::default()).

Source

pub const fn orientation(&self) -> Orientation

Pending EXIF display orientation attached to this mutable view.

Source

pub const fn display_dimensions(&self) -> (u32, u32)

Display-oriented (width, height) after applying orientation.

Source

pub const fn with_orientation( self, orientation: Orientation, ) -> PixelViewMut<'a>

Replace the pending EXIF display orientation on this mutable view.

Source

pub fn set_orientation(&mut self, orientation: Orientation)

Set the pending EXIF display orientation on this mutable view in place.

Source

pub const fn compose_orientation(self, delta: Orientation) -> PixelViewMut<'a>

Compose an additional display transform (including reflections) onto this view’s pending orientation (self.orientation.then(delta)) in O(1) without touching pixels.

Source

pub const fn width(&self) -> u32

Width in pixels.

Source

pub const fn height(&self) -> u32

Height in rows.

Source

pub const fn stride_bytes(&self) -> usize

Row stride in bytes.

Source

pub fn row_bytes(&self) -> usize

Active bytes per row.

Source

pub fn format(&self) -> &PixelFormat

Authoritative image specification.

Source

pub fn row_mut(&mut self, y: u32) -> &mut [u8] ⓘ

Mutable active bytes of row y.

Source

pub fn row_as_mut<P>(&mut self, y: u32) -> Result<&mut [P], At<BufferError>>
where P: TypedElement,

Zero-copy layout-checked mutable typed slice of row y (e.g. &mut [rgb::Rgba<u8>], &mut [[f32; 3]], &mut [u16]).

Semantically validates P::matches_layout(self.format().layout) — rejecting mismatched sample types, mismatched channel orders, and non-Full BitPacking. Use row_as_mut_with for explicit BitPackingAccess, or row_transmute_mut for intentional raw-POD reinterpretation.

Source

pub fn row_as_mut_with<P>( &mut self, y: u32, packing: BitPackingAccess, ) -> Result<&mut [P], At<BufferError>>
where P: TypedElement,

Zero-copy layout-checked mutable typed slice of row y with an explicit BitPackingAccess policy (Fail or PassThrough).

Source

pub fn row_samples_mut<S>( &mut self, y: u32, ) -> Result<&mut [S], At<BufferError>>
where S: StorageSample,

Zero-copy sample-checked native-endian mutable slice of row y (e.g. &mut [u16]).

Rejects non-Full BitPacking and mismatched sample types with BufferError::IncompatibleLayout.

Source

pub fn row_samples_mut_with<S>( &mut self, y: u32, packing: BitPackingAccess, ) -> Result<&mut [S], At<BufferError>>
where S: StorageSample,

Zero-copy sample-checked native-endian mutable slice of row y with an explicit BitPackingAccess policy (Fail or PassThrough).

Source

pub fn row_transmute_mut<P>( &mut self, y: u32, ) -> Result<&mut [P], At<BufferError>>
where P: Pod,

Safe raw-POD mutable byte reinterpretation of row y (bytemuck::try_cast_slice_mut), checking bounds, alignment, and byte divisibility without semantic layout validation.

Source

pub fn mutate_rows_with_packing<S, Pre, Post, F>( &mut self, mode: BitPackingTransform<Pre, Post>, f: F, ) -> Result<(), At<BufferError>>
where S: StorageSample, Pre: FnMut(BitPacking, &mut [S]), Post: FnMut(BitPacking, &mut [S]), F: FnMut(u32, &mut [S]) -> Result<(), At<BufferError>>,

Mutate every row in place as &mut [S] with an explicit BitPackingTransform policy (Fail, PassThrough, or PrePost { norm, denorm }).

When layout.packing == BitPacking::Full, runs f(y, row) directly with zero pre/post overhead. When PrePost { norm, denorm } runs on a non-Full layout, norm(packing, row) runs before f(y, row) and denorm(packing, row) is guaranteed to run afterwards (even on Err or unwind) so rows are never left in a half-normalized state.

Source

pub fn as_strided_bytes_mut(&mut self) -> &mut [u8] ⓘ

Mutable raw strided byte backing starting at (0, 0) (includes inter-row padding).

Source

pub fn is_contiguous(&self) -> bool

Whether rows are tightly packed (stride_bytes == row_bytes or height <= 1).

Source

pub fn as_contiguous_bytes_mut(&mut self) -> Option<&mut [u8]>

Mutable contiguous bytes if rows are tightly packed.

Source

pub fn as_contiguous_typed_mut<P>( &mut self, ) -> Result<&mut [P], At<BufferError>>
where P: TypedElement,

Zero-copy layout-checked mutable contiguous typed slice across all rows (e.g. &mut [rgb::Rgb<u16>], &mut [[f32; 4]], &mut [u16]).

Semantically validates P::matches_layout(self.format().layout) and tight row packing. For intentional raw-POD reinterpretation, use as_contiguous_transmute_mut.

Source

pub fn as_contiguous_typed_mut_with<P>( &mut self, packing: BitPackingAccess, ) -> Result<&mut [P], At<BufferError>>
where P: TypedElement,

Zero-copy layout-checked mutable contiguous typed slice across all rows with an explicit BitPackingAccess policy (Fail or PassThrough).

Source

pub fn as_contiguous_samples_mut<S>( &mut self, ) -> Result<&mut [S], At<BufferError>>
where S: StorageSample,

Zero-copy sample-checked native-endian mutable contiguous slice across all rows (e.g. &mut [u16]).

Rejects padded rows, non-Full bit packing, and mismatched sample types.

Source

pub fn as_contiguous_samples_mut_with<S>( &mut self, packing: BitPackingAccess, ) -> Result<&mut [S], At<BufferError>>
where S: StorageSample,

Zero-copy sample-checked native-endian mutable contiguous slice across all rows with an explicit BitPackingAccess policy (Fail or PassThrough).

Source

pub fn as_contiguous_transmute_mut<P>( &mut self, ) -> Result<&mut [P], At<BufferError>>
where P: Pod,

Safe raw-POD mutable byte reinterpretation across contiguous rows (bytemuck::try_cast_slice_mut), checking tight row packing, alignment, and byte divisibility without semantic layout validation.

Source

pub fn as_view(&self) -> PixelView<'_>

Borrow as an immutable PixelView (zero Arc refcount bump).

Source

pub fn into_view(self) -> PixelView<'a>

Downgrade into an immutable PixelView<'a> keeping 'a.

Source

pub fn into_strided_bytes_mut(self) -> &'a mut [u8] ⓘ

Consume this mutable view and return the underlying strided backing slice tied to 'a.

Source

pub fn crop_mut( &mut self, rect: PixelRect, ) -> Result<PixelViewMut<'_>, At<BufferError>>

Mutable rectangular subimage view (zero Arc refcount bump).

Source

pub fn sub_rows_mut( &mut self, start_y: u32, row_count: u32, ) -> Result<PixelViewMut<'_>, At<BufferError>>

Mutable full-width strip view.

Source

pub fn into_crop( self, rect: PixelRect, ) -> Result<PixelViewMut<'a>, At<BufferError>>

Consume this mutable view and narrow it to a rectangular crop retaining 'a.

Source

pub fn into_sub_rows( self, start_y: u32, row_count: u32, ) -> Result<PixelViewMut<'a>, At<BufferError>>

Consume this mutable view and narrow it to a full-width strip retaining 'a.

Source§

impl PixelViewMut<'_>

Source

pub fn hash_with(&self, inclusions: HashInclusions) -> u64

Compute a portable, endian- and stride-independent XXH3 fingerprint of this mutable view.

Source§

impl<'a> PixelViewMut<'a>

Source

pub fn from_imgref_mut<P>( img: Img<&'a mut [P]>, color: ColorSpace, ) -> Result<PixelViewMut<'a>, At<BufferError>>
where P: PixelType,

Borrow a mutable typed [imgref::ImgRefMut<'a, P>] zero-copy with true 'a lifetime.

Uses a zero-allocation &'static PixelFormat for all standard built-in presets, and allocates an Arc<PixelFormat> only for custom/ICC color spaces.

Source

pub fn as_imgref_mut<P>(&mut self) -> Result<Img<&mut [P]>, At<BufferError>>
where P: PixelType,

Borrow as a mutable zero-copy [imgref::ImgRefMut<'_, P>].

Source

pub fn into_imgref_mut<P>(self) -> Result<Img<&'a mut [P]>, At<BufferError>>
where P: PixelType,

Consume this mutable view and convert into a zero-copy [imgref::ImgRefMut<'a, P>] retaining 'a.

Source

pub fn as_sample_imgref_mut<S>( &mut self, ) -> Result<Img<&mut [S]>, At<BufferError>>
where S: StorageSample,

Borrow as a mutable sample-strided zero-copy [imgref::ImgRefMut<'_, S>].

Source§

impl<'a> PixelViewMut<'a>

Source

pub fn from_image_buffer_mut<P, C>( img: &'a mut ImageBuffer<P, C>, ) -> Result<PixelViewMut<'a>, At<BufferError>>
where P: Pixel + PixelWithColorType + 'static, <P as Pixel>::Subpixel: StorageSample, C: Deref<Target = [<P as Pixel>::Subpixel]> + DerefMut,

Mutably borrow any image::ImageBuffer<P, C> zero-copy for all 10 standard formats.

Uses a zero-allocation &'static PixelFormat for all standard sRGB / linear formats, and allocates an Arc<PixelFormat> only for non-preset CICP color spaces.

Source

pub fn from_dynamic_image_mut( img: &'a mut DynamicImage, ) -> Result<PixelViewMut<'a>, At<BufferError>>

Mutably borrow an image::DynamicImage zero-copy for all 10 standard variants.

Trait Implementations§

Source§

impl<'a> Debug for PixelViewMut<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PixelSink for PixelViewMut<'_>

Source§

fn sink_width(&self) -> u32

Frame width in pixels.
Source§

fn sink_height(&self) -> u32

Frame height in rows.
Source§

fn sink_format(&self) -> &PixelFormat

Authoritative destination specification.
Source§

fn sink_row_mut(&mut self, y: u32) -> Result<&mut [u8], At<BufferError>>

Fallibly borrow mutable active bytes of row y. Read more
Source§

fn sink_set_orientation(&mut self, orientation: Orientation)

Propagate pending EXIF display orientation onto sinks.
Source§

fn sink_finish(&mut self, _claims: SampleClaims, _hdr: HdrMetadata)

Propagate output claims & HDR metadata on owned sinks (no-op on borrowed views).
Source§

fn sink_set_origin(&mut self, _origin: ColorOrigin)

Propagate original container color provenance onto owned sinks (no-op on borrowed views).

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for PixelViewMut<'a>

§

impl<'a> Freeze for PixelViewMut<'a>

§

impl<'a> RefUnwindSafe for PixelViewMut<'a>

§

impl<'a> Send for PixelViewMut<'a>

§

impl<'a> Sync for PixelViewMut<'a>

§

impl<'a> Unpin for PixelViewMut<'a>

§

impl<'a> UnsafeUnpin for PixelViewMut<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.