feim 0.25.1

Modular crate for working with images in Rust
Documentation
pub mod convert;

#[cfg(feature = "col-cmyk")]
mod cmyk;
#[cfg(feature = "col-gray")]
mod gray;
#[cfg(feature = "col-gray16")]
mod gray16;
#[cfg(feature = "col-nrgba")]
mod nrgba;
#[cfg(feature = "col-nrgba64")]
mod nrgba64;
#[cfg(feature = "col-nrgba-float")]
mod nrgba_float;
#[cfg(feature = "col-oklab")]
mod oklab;
#[cfg(feature = "col-rgb")]
mod rgb;
#[cfg(feature = "col-rgb48")]
mod rgb48;
#[cfg(feature = "col-rgb-float")]
mod rgb_float;

#[cfg(feature = "col-cmyk")]
pub use cmyk::*;
#[cfg(feature = "col-gray")]
pub use gray::*;
#[cfg(feature = "col-gray16")]
pub use gray16::*;
#[cfg(feature = "col-nrgba")]
pub use nrgba::*;
#[cfg(feature = "col-nrgba64")]
pub use nrgba64::*;
#[cfg(feature = "col-nrgba-float")]
pub use nrgba_float::*;
#[cfg(feature = "col-oklab")]
pub use oklab::*;
#[cfg(feature = "col-rgb")]
pub use rgb::*;
#[cfg(feature = "col-rgb48")]
pub use rgb48::*;
#[cfg(feature = "col-rgb-float")]
pub use rgb_float::*;

/// A color which contains a zero value.
pub trait Zero: Color + Copy {
    /// The zero value of this color.
    const ZERO: Self;
}

pub trait Color {
    /// Return an alpha premultiplied color in RGBA 16 bits.
    ///
    /// Components are returned as native-endian values.
    fn as_rgba(&self) -> (u32, u32, u32, u32);
}

// -------------------------------------------------------------------------- //

/// Tag a pixel's channel value as big-endian.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum BigEndian {}

/// Tag a pixel's channel value as little-endian.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum LittleEndian {}

/// Tag a pixel's channel value as native-endian.
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum NativeEndian {}

// -------------------------------------------------------------------------- //

#[doc(hidden)]
pub trait EndiannessPrivate {}

pub trait Endianness: EndiannessPrivate {}

impl EndiannessPrivate for BigEndian {}

impl EndiannessPrivate for LittleEndian {}

impl EndiannessPrivate for NativeEndian {}

impl<E: EndiannessPrivate> Endianness for E {}