pub struct ImagePlanes { /* private fields */ }Expand description
Planar image: one retained device buffer per channel, independent dtype.
Each plane is a flat row-major array of width * height elements. Missing
alpha (fewer than 4 channels) defaults to 1.0 in the blit shader. The
value owns its plane storage; cloning plane buffers for frame retention is
internal to Ui.
Donor: oa::ImagePlanes.
Implementations§
Source§impl ImagePlanes
impl ImagePlanes
Sourcepub fn plane_dtype(&self, channel: usize) -> ImageDtype
pub fn plane_dtype(&self, channel: usize) -> ImageDtype
Return the dtype stored for channel (U8 when out of range).
Sourcepub fn channel_count(&self) -> usize
pub fn channel_count(&self) -> usize
Return the number of planes (1–4).
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Return whether the image has positive dimensions and live planes.
Sourcepub fn load_file(path: impl AsRef<Path>) -> Result<Self>
pub fn load_file(path: impl AsRef<Path>) -> Result<Self>
Decode a supported image file into planar channels.
Preserves the file’s channel count: 1=gray, 2=gray+alpha, 3=RGB,
4=RGBA. 8-bit files upload U8 planes, 16-bit files U16, and
floating-point (HDR) files F32. This is a synchronous host codec
boundary followed by device uploads.
§Errors
Returns an error for an unreadable, unsupported, or malformed file, checked-size overflow, or device upload failure.
This variant loads on this thread’s default runtime. An runtime initialization failure is returned before decoding starts.
Sourcepub fn from_planes(
planes: &[&[u8]],
dtypes: &[ImageDtype],
width: i32,
height: i32,
) -> Result<Self>
pub fn from_planes( planes: &[&[u8]], dtypes: &[ImageDtype], width: i32, height: i32, ) -> Result<Self>
Upload caller-provided planes.
planes and dtypes must have the same length (1–4); each span holds
exactly width * height * sizeof(dtype) bytes. Synchronous.
§Errors
Returns an error for a channel count outside 1–4, a planes/dtypes length mismatch, non-positive or overflowing dimensions, a plane byte size that does not match its dtype, or device upload failure.
This variant uploads on this thread’s default runtime. An runtime initialization failure is returned before the upload starts.
Sourcepub fn from_planes_on(
runtime: &Runtime,
planes: &[&[u8]],
dtypes: &[ImageDtype],
width: i32,
height: i32,
) -> Result<Self>
pub fn from_planes_on( runtime: &Runtime, planes: &[&[u8]], dtypes: &[ImageDtype], width: i32, height: i32, ) -> Result<Self>
Upload caller-provided planes on a particular runtime.
This is the from_planes contract evaluated on
runtime instead of this thread’s default runtime.
§Errors
Returns the same errors as from_planes.