pub struct ImageDescriptor<'a> {
pub format: PixelFormat,
pub width: u16,
pub height: u16,
pub data: ImageData<'a>,
pub stride: Option<u32>,
}Expand description
Description of an image’s dimensions, format, storage, and row stride.
Fields§
§format: PixelFormatPixel layout used by the image data.
width: u16Width in pixels.
height: u16Height in pixels.
data: ImageData<'a>Pixel bytes or safe borrowed color pixels.
stride: Option<u32>Bytes per row; None means tightly packed rows.
Implementations§
Source§impl<'a> ImageDescriptor<'a>
impl<'a> ImageDescriptor<'a>
Sourcepub const fn new(
format: PixelFormat,
width: u16,
height: u16,
data: ImageData<'a>,
stride: Option<u32>,
) -> Self
pub const fn new( format: PixelFormat, width: u16, height: u16, data: ImageData<'a>, stride: Option<u32>, ) -> Self
Create an image descriptor from explicit parts.
Sourcepub const fn borrowed(
format: PixelFormat,
width: u16,
height: u16,
data: &'a [u8],
) -> Self
pub const fn borrowed( format: PixelFormat, width: u16, height: u16, data: &'a [u8], ) -> Self
Create a tightly packed descriptor over borrowed encoded pixel bytes.
Sourcepub fn owned(
format: PixelFormat,
width: u16,
height: u16,
data: Vec<u8>,
) -> Self
pub fn owned( format: PixelFormat, width: u16, height: u16, data: Vec<u8>, ) -> Self
Create a tightly packed descriptor over owned encoded pixel bytes.
Sourcepub const fn from_color_slice(
pixels: &'a [Color],
width: u16,
height: u16,
) -> Self
pub const fn from_color_slice( pixels: &'a [Color], width: u16, height: u16, ) -> Self
Create a zero-copy ARGB8888 descriptor over borrowed Color pixels.
The descriptor uses ImageData::BorrowedColors instead of exposing
raw bytes because Color does not define a stable memory layout. The
effective representation is still ARGB8888: consumers serialize each
color through Color::to_argb8888 when byte output is needed.
Sourcepub const fn dimensions(&self) -> (u16, u16)
pub const fn dimensions(&self) -> (u16, u16)
Return (width, height) in pixels.
Sourcepub const fn tightly_packed_stride(&self) -> u32
pub const fn tightly_packed_stride(&self) -> u32
Return the bytes per row for tightly packed rows.
Sourcepub fn stride_bytes(&self) -> u32
pub fn stride_bytes(&self) -> u32
Return the effective bytes per row.
Sourcepub fn is_tightly_packed(&self) -> bool
pub fn is_tightly_packed(&self) -> bool
Return true when rows are tightly packed with no padding bytes.
Trait Implementations§
Source§impl<'a> Clone for ImageDescriptor<'a>
impl<'a> Clone for ImageDescriptor<'a>
Source§fn clone(&self) -> ImageDescriptor<'a>
fn clone(&self) -> ImageDescriptor<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more