Struct NdImage

Source
pub struct NdImage<T>(pub T);
Expand description

This newtype struct can wrap an image from either the ndarray or image crates to automatically allow them to be turned into() the equivalents in the other crate. This works without copying.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<'a, C, A> Into<ArrayBase<ViewRepr<&'a A>, Dim<[usize; 2]>>> for NdImage<&'a ImageBuffer<Luma<A>, C>>
where A: Primitive + 'static, C: Deref<Target = [A]> + AsRef<[A]>,

Turn grayscale images into 2d array views.

Source§

fn into(self) -> NdGray<'a, A>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, C, P, A> Into<ArrayBase<ViewRepr<&'a A>, Dim<[usize; 3]>>> for NdImage<&'a ImageBuffer<P, C>>
where A: Primitive + 'static, P: Pixel<Subpixel = A> + 'static, C: Deref<Target = [P::Subpixel]> + AsRef<[A]>,

Turn arbitrary images into 3d array views with one dimension for the color channel.

Source§

fn into(self) -> NdColor<'a, A>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, C, A> Into<ArrayBase<ViewRepr<&'a mut A>, Dim<[usize; 2]>>> for NdImage<&'a mut ImageBuffer<Luma<A>, C>>
where A: Primitive + 'static, C: Deref<Target = [A]> + AsRef<[A]>,

Turn grayscale images into mutable 2d array views.

Source§

fn into(self) -> NdGrayMut<'a, A>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, C, P, A> Into<ArrayBase<ViewRepr<&'a mut A>, Dim<[usize; 3]>>> for NdImage<&'a mut ImageBuffer<P, C>>
where A: Primitive + 'static, P: Pixel<Subpixel = A> + 'static, C: Deref<Target = [P::Subpixel]> + AsRef<[A]>,

Turn arbitrary images into mutable 3d array views with one dimension for the color channel.

Source§

fn into(self) -> NdColorMut<'a, A>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Bgr<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a Bgr image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgBgr<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Bgra<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a Bgra image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgBgra<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Luma<A>, &'a [A]>>> for NdImage<NdGray<'a, A>>
where A: Primitive + 'static,

Turn 2d ArrayView into a Luma image.

Can fail if the ArrayView is not contiguous.

Source§

fn into(self) -> Option<ImgLuma<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Luma<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a Luma image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgLuma<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<LumaA<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a LumaA image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgLumaA<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Rgb<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a Rgb image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgRgb<'a, A>>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, A> Into<Option<ImageBuffer<Rgba<A>, &'a [A]>>> for NdImage<NdColor<'a, A>>
where A: Primitive + 'static,

Turn 3d ArrayView into a Rgba image.

Can fail if the ArrayView is not contiguous or has the wrong number of channels.

Source§

fn into(self) -> Option<ImgRgba<'a, A>>

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<T> Freeze for NdImage<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for NdImage<T>
where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for NdImage<T>
where T: Unpin,

§

impl<T> UnwindSafe for NdImage<T>
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<'a, A, D, T> AsArray<'a, A, D> for T
where A: 'a, T: Into<ArrayBase<ViewRepr<&'a A>, D>>, D: Dimension,