Enum fimg::DynImage

source ·
pub enum DynImage<T> {
    Y(Image<T, 1>),
    Ya(Image<T, 2>),
    Rgb(Image<T, 3>),
    Rgba(Image<T, 4>),
}
Expand description

Dynamic image. Can be any of {Y8, YA8, RGB8, RGB16}.

Variants§

§

Y(Image<T, 1>)

Y image

§

Ya(Image<T, 2>)

YA image

§

Rgb(Image<T, 3>)

RGB image

§

Rgba(Image<T, 4>)

RGBA image

Implementations§

source§

impl<T: AsMut<[u8]> + AsRef<[u8]>> DynImage<T>

source

pub unsafe fn rot_90(&mut self)

Rotate this image 90 degrees clockwise.

§Safety

UB if this image is not square

source

pub fn rot_180(&mut self)

Rotate this image 180 degrees clockwise.

source

pub unsafe fn rot_270(&mut self)

Rotate this image 270 degrees clockwise.

§Safety

UB if this image is not square

source

pub fn flip_h(&mut self)

Flip this image horizontally.

source

pub fn flip_v(&mut self)

Flip this image vertically.

source§

impl<T> DynImage<T>

source

pub fn get_y(self) -> Result<Image<T, 1>, Self>

Gets out the Y image, if its there, else returning self.

If you want to convert, see DynImage::to_y.

source

pub fn get_ya(self) -> Result<Image<T, 2>, Self>

Gets out the YA image, if its there, else returning self.

If you want to convert, see DynImage::to_ya.

source

pub fn get_rgb(self) -> Result<Image<T, 3>, Self>

Gets out the RGB image, if its there, else returning self.

If you want to convert, see DynImage::to_rgb.

source

pub fn get_rgba(self) -> Result<Image<T, 4>, Self>

Gets out the RGBA image, if its there, else returning self.

If you want to convert, see DynImage::to_rgba.

source§

impl DynImage<Box<[u8]>>

source

pub fn to_y(self) -> Image<Box<[u8]>, 1>

Convert this dyn image into a Y image.

source

pub fn to_ya(self) -> Image<Box<[u8]>, 2>

Convert this dyn image into a YA image.

source

pub fn to_rgb(self) -> Image<Box<[u8]>, 3>

Convert this dyn image into a RGB image.

source

pub fn to_rgba(self) -> Image<Box<[u8]>, 4>

Convert this dyn image into a RGBA image.

source§

impl<T: AsRef<[u8]>> DynImage<T>

source

pub fn y(&self) -> Image<Box<[u8]>, 1>

Produce a Y image from this dyn image.

source

pub fn ya(&self) -> Image<Box<[u8]>, 2>

Produce a YA image from this dyn image.

source

pub fn rgb(&self) -> Image<Box<[u8]>, 3>

Produce a RGB image from this dyn image.

source

pub fn rgba(&self) -> Image<Box<[u8]>, 4>

Produce a RGBA image from this dyn image.

source§

impl<T: AsMut<[u8]> + AsRef<[u8]>> DynImage<T>

source

pub fn scale<A: ScalingAlgorithm>( &mut self, width: u32, height: u32 ) -> DynImage<Box<[u8]>>

Available on crate feature scale only.

Scale this image with a given scaling algorithm.

source§

impl<T> DynImage<T>

source

pub const fn width(&self) -> u32

Get the width of this image.

source

pub const fn height(&self) -> u32

Get the height of this image.

source

pub const fn buffer(&self) -> &T

Get the image buffer.

source

pub fn take_buffer(self) -> T

Take the image buffer.

source§

impl<T: AsRef<[u8]>> DynImage<T>

source

pub fn as_ref(&self) -> DynImage<&[u8]>

Reference this image.

source

pub unsafe fn pixel<const P: usize>(&self, x: u32, y: u32) -> [u8; P]
where [u8; P]: PFrom<1> + PFrom<2> + PFrom<3> + PFrom<4>,

Get a pixel, of a type.

let i = DynImage::Rgb(Image::alloc(50, 50));
assert_eq!(unsafe { i.pixel::<4>(25, 25) }, [0, 0, 0, 255]);
§Safety

undefined behaviour if pixel is out of bounds.

source

pub fn bytes(&self) -> &[u8]

Bytes of this image.

source§

impl DynImage<Box<[u8]>>

source

pub fn open(f: impl AsRef<Path>) -> Self

Available on crate feature save only.

Open a PNG image

source

pub fn save(&self, f: impl AsRef<Path>)

Available on crate feature save only.

Save this image to a PNG.

Trait Implementations§

source§

impl<T: Clone> Clone for DynImage<T>

source§

fn clone(&self) -> DynImage<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for DynImage<T>

source§

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

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

impl<T: AsRef<[u8]>> Display for DynImage<T>

Available on crate feature term only.
source§

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

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

impl From<DynImage<Box<[u8]>>> for Image<Box<[u8]>, 1>

source§

fn from(value: DynImage<Box<[u8]>>) -> Self

Converts to this type from the input type.
source§

impl From<DynImage<Box<[u8]>>> for Image<Box<[u8]>, 2>

source§

fn from(value: DynImage<Box<[u8]>>) -> Self

Converts to this type from the input type.
source§

impl From<DynImage<Box<[u8]>>> for Image<Box<[u8]>, 3>

source§

fn from(value: DynImage<Box<[u8]>>) -> Self

Converts to this type from the input type.
source§

impl From<DynImage<Box<[u8]>>> for Image<Box<[u8]>, 4>

source§

fn from(value: DynImage<Box<[u8]>>) -> Self

Converts to this type from the input type.
source§

impl<T: PartialEq> PartialEq for DynImage<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for DynImage<&[u8]>

source§

impl<T> StructuralPartialEq for DynImage<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for DynImage<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> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

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

source§

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

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

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

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

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

source§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Join<T, 1, 1, T> for T

source§

const fn join(self, with: T) -> [T; 2]

Join a array and an scalar together. For joining two arrays together, see Couple. Read more
source§

impl<T, const O: usize> Join<T, 1, O, [T; O]> for T

source§

const fn join(self, with: [T; O]) -> [T; { _ }]

Join a array and an scalar together. For joining two arrays together, see Couple. Read more
source§

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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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

source§

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

source§

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

source§

impl<T> WasmNotSendSync for T

source§

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