#[non_exhaustive]pub struct CpuTile { /* private fields */ }Expand description
Generic decoded pixel buffer.
Invariant: data length must equal width * height * channels in samples.
Use CpuTile::new() to construct with validation, and use the read
accessors for metadata and pixel storage.
Implementations§
Source§impl CpuTile
impl CpuTile
Sourcepub fn new(
width: u32,
height: u32,
channels: u16,
color_space: ColorSpace,
layout: CpuTileLayout,
data: CpuTileData,
) -> Result<Self, WsiError>
pub fn new( width: u32, height: u32, channels: u16, color_space: ColorSpace, layout: CpuTileLayout, data: CpuTileData, ) -> Result<Self, WsiError>
Construct a CpuTile, validating that the data length matches
width * height * channels. Uses checked arithmetic to prevent
overflow on large dimensions.
Sourcepub fn from_u8_interleaved(
width: u32,
height: u32,
channels: u16,
color_space: ColorSpace,
pixels: Vec<u8>,
) -> Result<Self, WsiError>
pub fn from_u8_interleaved( width: u32, height: u32, channels: u16, color_space: ColorSpace, pixels: Vec<u8>, ) -> Result<Self, WsiError>
Construct an interleaved U8 CPU tile.
pub fn width(&self) -> u32
pub fn height(&self) -> u32
pub fn channels(&self) -> u16
pub fn color_space(&self) -> &ColorSpace
pub fn layout(&self) -> CpuTileLayout
pub fn data(&self) -> &CpuTileData
pub fn stride_bytes(&self) -> usize
pub fn as_u8(&self) -> Option<&[u8]>
pub fn pixels_arc(&self) -> Option<Arc<[u8]>>
Sourcepub fn to_rgba(&self) -> Result<RgbaImage, WsiError>
pub fn to_rgba(&self) -> Result<RgbaImage, WsiError>
Convert Uint8 data to RgbaImage. Returns error for non-Uint8 data.
Sourcepub fn into_rgba(self) -> Result<RgbaImage, WsiError>
pub fn into_rgba(self) -> Result<RgbaImage, WsiError>
Convert this buffer into an owned RgbaImage, reusing the underlying byte vector directly when the buffer is already RGBA8 interleaved.
Sourcepub fn to_rgba_windowed(
&self,
window: &DisplayWindow,
) -> Result<RgbaImage, WsiError>
pub fn to_rgba_windowed( &self, window: &DisplayWindow, ) -> Result<RgbaImage, WsiError>
Convert any sample type to RgbaImage with explicit windowing.
Sourcepub fn to_rgb(&self) -> Result<RgbImage, WsiError>
pub fn to_rgb(&self) -> Result<RgbImage, WsiError>
Convert Uint8 data to RgbImage. Direct path for RGB8 and Grayscale; other color spaces fall through RGBA conversion.
Sourcepub fn into_rgb(self) -> Result<RgbImage, WsiError>
pub fn into_rgb(self) -> Result<RgbImage, WsiError>
Convert this buffer into an owned RgbImage, reusing the underlying byte vector directly when the buffer is already RGB8 interleaved.
Sourcepub fn to_rgb_windowed(
&self,
window: &DisplayWindow,
) -> Result<RgbImage, WsiError>
pub fn to_rgb_windowed( &self, window: &DisplayWindow, ) -> Result<RgbImage, WsiError>
Convert any sample type to RgbImage with explicit windowing. Direct path avoids intermediate RGBA allocation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CpuTile
impl RefUnwindSafe for CpuTile
impl Send for CpuTile
impl Sync for CpuTile
impl Unpin for CpuTile
impl UnsafeUnpin for CpuTile
impl UnwindSafe for CpuTile
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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