#[non_exhaustive]pub struct RawFormat {
pub descriptor: ImageDescriptor,
pub stride: usize,
}Expand description
The layout of a raw pixel stream.
Raw carries no self-description, so this is the contract the caller must supply on both the decode and encode side.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.descriptor: ImageDescriptorDimensions and pixel format of the stream.
stride: usizeBytes between the starts of consecutive rows in the stream.
At least descriptor.row_bytes(). Any excess is row padding, which the
decoder reads and discards and the encoder writes as zeroes — this is
how raw dumps from graphics APIs with aligned rows are consumed.
Implementations§
Source§impl RawFormat
impl RawFormat
Sourcepub const fn packed(descriptor: ImageDescriptor) -> Self
pub const fn packed(descriptor: ImageDescriptor) -> Self
A densely packed layout: stride equals one row of pixels.
Sourcepub fn with_stride(descriptor: ImageDescriptor, stride: usize) -> Result<Self>
pub fn with_stride(descriptor: ImageDescriptor, stride: usize) -> Result<Self>
A layout with explicit row padding.
§Errors
Returns PixelsError::InvalidArgument if stride is shorter than one
packed row.
Sourcepub fn from_dimensions(
width: u32,
height: u32,
pixel: PixelFormat,
limits: &Limits,
) -> Result<Self>
pub fn from_dimensions( width: u32, height: u32, pixel: PixelFormat, limits: &Limits, ) -> Result<Self>
Describe a raw stream from its dimensions, checked against limits.
This is the raw equivalent of a header parse: dimensions are validated before any pixel buffer is allocated (SPEC §Safety), so a caller forwarding untrusted dimensions cannot provoke a huge allocation.
§Errors
Returns PixelsError::LimitExceeded if the dimensions exceed
limits, or PixelsError::InvalidArgument if either is zero.