Skip to main content

ImagePlanes

Struct ImagePlanes 

Source
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

Source

pub fn plane_dtype(&self, channel: usize) -> ImageDtype

Return the dtype stored for channel (U8 when out of range).

Source

pub const fn width(&self) -> i32

Return the image width in pixels.

Source

pub const fn height(&self) -> i32

Return the image height in pixels.

Source

pub fn channel_count(&self) -> usize

Return the number of planes (1–4).

Source

pub fn is_valid(&self) -> bool

Return whether the image has positive dimensions and live planes.

Source

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.

Source

pub fn load_file_on(runtime: &Runtime, path: impl AsRef<Path>) -> Result<Self>

Load an image file into device-uploaded planes on a particular runtime.

This is the load_file contract evaluated on runtime instead of this thread’s default runtime.

§Errors

Returns the same errors as load_file.

Source

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.

Source

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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ImagePlanes

§

impl !Send for ImagePlanes

§

impl !Sync for ImagePlanes

§

impl !UnwindSafe for ImagePlanes

§

impl Forget for ImagePlanes

§

impl Freeze for ImagePlanes
where *const RcInner<RefCell<RuntimeState>> is !null: Freeze, PhantomData<RcInner<RefCell<RuntimeState>>>: Freeze, *const u8 is !null: Freeze, PhantomData<Matrix>: Freeze, PhantomData<ImageDtype>: Freeze,

§

impl Move for ImagePlanes

§

impl Unpin for ImagePlanes
where Rc<RefCell<RuntimeState>>: Unpin, *const u8 is !null: Unpin, Rc<StorageInner>: Unpin, Rc<MatrixSemantic>: Unpin, Rc<()>: Unpin,

§

impl UnsafeUnpin for ImagePlanes
where *const RcInner<RefCell<RuntimeState>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<RuntimeState>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Matrix>: UnsafeUnpin, PhantomData<ImageDtype>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.