zune_core::colorspace

Enum ColorSpace

Source
#[non_exhaustive]
pub enum ColorSpace {
Show 13 variants RGB, RGBA, YCbCr, Luma, LumaA, YCCK, CMYK, BGR, BGRA, Unknown, ARGB, HSL, HSV,
}
Expand description

All possible image colorspaces Some of them aren’t yet supported exist here.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

RGB

Red, Green , Blue

§

RGBA

Red, Green, Blue, Alpha

§

YCbCr

YUV colorspace

§

Luma

Grayscale colorspace

§

LumaA

Grayscale with alpha colorspace

§

YCCK

§

CMYK

Cyan , Magenta, Yellow, Black

§

BGR

Blue, Green, Red

§

BGRA

Blue, Green, Red, Alpha

§

Unknown

The colorspace is unknown

§

ARGB

Alpha Red Green Blue

§

HSL

Hue,Saturation,Lightness Conversion from RGB to HSL and back matches that of Python colorsys module Color type is expected to be in floating point

§

HSV

Hue, Saturation,Value

Conversion from RGB to HSV and back matches that of Python colorsys module Color type is expected to be in floating point

Implementations§

Source§

impl ColorSpace

Source

pub const fn num_components(&self) -> usize

Number of color channels present for a certain colorspace

E.g. RGB returns 3 since it contains R,G and B colors to make up a pixel

Source

pub const fn has_alpha(&self) -> bool

Source

pub const fn is_grayscale(&self) -> bool

Source

pub const fn alpha_position(&self) -> Option<usize>

Returns the position of the alpha pixel in a pixel

That is for an array of color components say [0,1,2,3] if the image has an alpha channel and is in RGBA format, this will return Some(3), indicating alpha is found in the third index but if the image is in ARGB format, it will return Some(0) indicating alpha is found in
index 0

If an image doesn’t have an alpha channel returns None

Trait Implementations§

Source§

impl Clone for ColorSpace

Source§

fn clone(&self) -> ColorSpace

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 Debug for ColorSpace

Source§

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

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

impl PartialEq for ColorSpace

Source§

fn eq(&self, other: &ColorSpace) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for ColorSpace

Source§

impl Eq for ColorSpace

Source§

impl StructuralPartialEq for ColorSpace

Auto Trait Implementations§

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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.