Skip to main content

Image

Struct Image 

Source
pub struct Image<T, const CHANNELS: usize> { /* private fields */ }
Expand description

An owning, densely packed, interleaved image.

Implementations§

Source§

impl<T, const CHANNELS: usize> Image<T, CHANNELS>

Source

pub fn try_new( width: usize, height: usize, data: Vec<T>, ) -> Result<Image<T, CHANNELS>, ImageError>

Creates an image from densely packed, interleaved scalar elements.

Source

pub fn try_new_with_metadata( width: usize, height: usize, data: Vec<T>, metadata: ImageMetadata, ) -> Result<Image<T, CHANNELS>, ImageError>

Creates a packed image and validates its semantic metadata.

Source

pub const fn width(&self) -> usize

Returns image width in pixels.

Source

pub const fn height(&self) -> usize

Returns image height in pixels.

Source

pub const fn row_stride(&self) -> usize

Returns the packed row stride in scalar elements.

Source

pub const fn layout(&self) -> ImageLayout

Returns physical channel layout.

Source

pub const fn metadata(&self) -> ImageMetadata

Returns semantic image metadata.

Source

pub fn set_metadata( &mut self, metadata: ImageMetadata, ) -> Result<(), ImageError>

Replaces semantic metadata after validating the channel count.

Source

pub fn as_slice(&self) -> &[T]

Returns the packed scalar storage.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns mutable packed scalar storage.

Source

pub fn view(&self) -> ImageView<'_, T, CHANNELS>

Borrows this image as a zero-copy view.

Source

pub fn view_mut(&mut self) -> ImageViewMut<'_, T, CHANNELS>

Borrows this image as a mutable zero-copy view.

Source

pub fn get(&self, x: usize, y: usize) -> Option<&[T; CHANNELS]>

Returns one pixel, or None outside image bounds.

Source

pub fn get_mut(&mut self, x: usize, y: usize) -> Option<&mut [T; CHANNELS]>

Returns one mutable pixel, or None outside image bounds.

Source

pub fn into_vec(self) -> Vec<T>

Consumes the image and returns its packed scalar storage.

Source§

impl<T, const CHANNELS: usize> Image<T, CHANNELS>
where T: Clone,

Source

pub fn from_pixel( width: usize, height: usize, pixel: [T; CHANNELS], ) -> Result<Image<T, CHANNELS>, ImageError>

Creates a densely packed image filled with one pixel value.

Trait Implementations§

Source§

impl<T, const CHANNELS: usize> Clone for Image<T, CHANNELS>
where T: Clone,

Source§

fn clone(&self) -> Image<T, CHANNELS>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, const CHANNELS: usize> Debug for Image<T, CHANNELS>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T, const CHANNELS: usize> Index<(usize, usize)> for Image<T, CHANNELS>

Source§

type Output = [T; CHANNELS]

The returned type after indexing.
Source§

fn index( &self, _: (usize, usize), ) -> &<Image<T, CHANNELS> as Index<(usize, usize)>>::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const CHANNELS: usize> IndexMut<(usize, usize)> for Image<T, CHANNELS>

Source§

fn index_mut( &mut self, _: (usize, usize), ) -> &mut <Image<T, CHANNELS> as Index<(usize, usize)>>::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, const CHANNELS: usize> PartialEq for Image<T, CHANNELS>
where T: PartialEq,

Source§

fn eq(&self, other: &Image<T, CHANNELS>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const CHANNELS: usize> Eq for Image<T, CHANNELS>
where T: Eq,

Source§

impl<T, const CHANNELS: usize> StructuralPartialEq for Image<T, CHANNELS>

Auto Trait Implementations§

§

impl<T, const CHANNELS: usize> Freeze for Image<T, CHANNELS>

§

impl<T, const CHANNELS: usize> RefUnwindSafe for Image<T, CHANNELS>
where T: RefUnwindSafe,

§

impl<T, const CHANNELS: usize> Send for Image<T, CHANNELS>
where T: Send,

§

impl<T, const CHANNELS: usize> Sync for Image<T, CHANNELS>
where T: Sync,

§

impl<T, const CHANNELS: usize> Unpin for Image<T, CHANNELS>
where T: Unpin,

§

impl<T, const CHANNELS: usize> UnsafeUnpin for Image<T, CHANNELS>

§

impl<T, const CHANNELS: usize> UnwindSafe for Image<T, CHANNELS>
where T: UnwindSafe,

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

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

§

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

§

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

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,