pub struct Image {
pub pixel: PixelFormat,
pub width: u32,
pub height: u32,
pub stride: u32,
pub data: ImageSamples,
}Expand description
A raw image frame — std/media/v1/Image[pixel=…], row-major and packed.
Fields§
§pixel: PixelFormatThe pixel format, which selects the sample column’s type.
width: u32The frame’s width in pixels.
height: u32The frame’s height in pixels.
stride: u32The bytes between the starts of two rows; equal to the packed row length for a frame with no padding, which is what this layout carries.
data: ImageSamplesThe samples, width * height * channels of them.
Implementations§
Source§impl Image
impl Image
Sourcepub fn new(
pixel: PixelFormat,
width: u32,
height: u32,
data: ImageSamples,
) -> Result<Self>
pub fn new( pixel: PixelFormat, width: u32, height: u32, data: ImageSamples, ) -> Result<Self>
A packed frame whose sample count matches its geometry.
stride is computed as the packed row length in bytes.
§Errors
DataError::TypeMismatch when the samples do not match the format’s
width, and DataError::ChildLengthMismatch when the sample count is
not width * height * channels.
Sourcepub fn to_record_batch(&self) -> Result<RecordBatch>
pub fn to_record_batch(&self) -> Result<RecordBatch>
Encodes the frame as a one-row payload batch.
§Errors
As Image::check, plus DataError when the columns cannot be
assembled.
Sourcepub fn from_record_batch(batch: &RecordBatch) -> Result<Self>
pub fn from_record_batch(batch: &RecordBatch) -> Result<Self>
Decodes a frame from a one-row payload batch.
The pixel format is recovered from the sample column’s type and the stored channel count, so a decoder never needs the port’s URN to read a frame it already holds.
§Errors
DataError when the batch is not an Image layout, or its sample
type and channel count name no format in the §24.3 table.