Enum ColorSpace

#[non_exhaustive]
pub enum ColorSpace

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

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

MultiBand(NonZeroU32)

Multiple arbitrary image channels.

This introduces limited support for multi-band/multichannel images that can have n channels.

The library contains optimized and well-supported routines for up to 4 image channels as is more common out there, but some pipelines may require multi-band image support.

For operations, multi-band images are assumed to be n-channel images with no alpha to allow for generic processing, without necessarily caring for the underlying interpretation

Implementations

impl ColorSpace

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

const fn has_alpha(&self) -> bool
const fn is_grayscale(&self) -> bool
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

impl Clone for ColorSpace

fn clone(&self) -> ColorSpace

impl Copy for ColorSpace

impl Debug for ColorSpace

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

impl Eq for ColorSpace

impl PartialEq for ColorSpace

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

impl StructuralPartialEq for ColorSpace

Auto Trait Implementations

impl Freeze for ColorSpace

impl RefUnwindSafe for ColorSpace

impl Send for ColorSpace

impl Sync for ColorSpace

impl Unpin for ColorSpace

impl UnsafeUnpin for ColorSpace

impl UnwindSafe for ColorSpace

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> CloneToUninit for ColorSpace where T: Clone,

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

impl<T> From<T> for ColorSpace

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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