pub struct JpegOutputBuffer { /* private fields */ }Expand description
Caller-owned reusable host pixel buffer.
The buffer uses a tight stride by default and can be resized across viewport
reads. Resizing to a same-or-smaller byte requirement keeps existing vector
capacity, so callers can reuse allocations while still passing ordinary
&mut [u8] slices into decode APIs.
Implementations§
Source§impl JpegOutputBuffer
impl JpegOutputBuffer
Sourcepub fn new(
dimensions: (u32, u32),
fmt: PixelFormat,
) -> Result<Self, BufferError>
pub fn new( dimensions: (u32, u32), fmt: PixelFormat, ) -> Result<Self, BufferError>
Create a tightly packed output buffer for dimensions and fmt.
Uses the shared default host allocation cap.
§Errors
Returns BufferError if the requested shape overflows byte counts,
exceeds the default host allocation cap, or cannot be reserved.
Sourcepub fn with_stride(
dimensions: (u32, u32),
stride: usize,
fmt: PixelFormat,
) -> Result<Self, BufferError>
pub fn with_stride( dimensions: (u32, u32), stride: usize, fmt: PixelFormat, ) -> Result<Self, BufferError>
Create an output buffer with an explicit row stride.
Uses the shared default host allocation cap.
§Errors
Returns BufferError if the stride is too small, sizes overflow, the
allocation exceeds the default host allocation cap, or reservation fails.
Sourcepub fn resize(
&mut self,
dimensions: (u32, u32),
fmt: PixelFormat,
) -> Result<(), BufferError>
pub fn resize( &mut self, dimensions: (u32, u32), fmt: PixelFormat, ) -> Result<(), BufferError>
Resize to a tightly packed output shape.
Uses the shared default host allocation cap.
Existing decoded bytes may be discarded when the allocation must grow or stale capacity exceeds the active cap.
§Errors
Returns BufferError if the requested shape overflows byte counts,
exceeds the default host allocation cap, or cannot be reserved.
Sourcepub fn resize_with_stride(
&mut self,
dimensions: (u32, u32),
stride: usize,
fmt: PixelFormat,
) -> Result<(), BufferError>
pub fn resize_with_stride( &mut self, dimensions: (u32, u32), stride: usize, fmt: PixelFormat, ) -> Result<(), BufferError>
Resize with an explicit row stride.
Uses the shared default host allocation cap. Existing decoded bytes may be discarded when storage must be replaced.
§Errors
Returns BufferError if the stride is too small, sizes overflow, the
allocation exceeds the default host allocation cap, or reservation fails.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Mutably borrow the decoded pixel bytes.
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Current dimensions in pixels.
Sourcepub fn pixel_format(&self) -> PixelFormat
pub fn pixel_format(&self) -> PixelFormat
Current pixel format.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JpegOutputBuffer
impl RefUnwindSafe for JpegOutputBuffer
impl Send for JpegOutputBuffer
impl Sync for JpegOutputBuffer
impl Unpin for JpegOutputBuffer
impl UnsafeUnpin for JpegOutputBuffer
impl UnwindSafe for JpegOutputBuffer
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
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>
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>
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