Trait pix::el::Pixel

source · []
pub trait Pixel: Clone + Copy + Debug + Default + PartialEq + Sealed {
    type Chan: Channel;
    type Model: ColorModel;
    type Alpha: Alpha;
    type Gamma: Gamma;

Show 22 methods fn from_channels(ch: &[Self::Chan]) -> Self; fn from_bit_depth<P>(p: P) -> Self
    where
        P: Pixel,
        Self::Chan: From<P::Chan>
; fn channels(&self) -> &[Self::Chan]; fn channels_mut(&mut self) -> &mut [Self::Chan]; fn one(self) -> Self::Chan { ... } fn one_mut(&mut self) -> &mut Self::Chan { ... } fn two(self) -> Self::Chan { ... } fn two_mut(&mut self) -> &mut Self::Chan { ... } fn three(self) -> Self::Chan { ... } fn three_mut(&mut self) -> &mut Self::Chan { ... } fn four(self) -> Self::Chan { ... } fn four_mut(&mut self) -> &mut Self::Chan { ... } fn alpha(self) -> Self::Chan { ... } fn alpha_mut(&mut self) -> &mut Self::Chan { ... } fn convert<D>(self) -> D
    where
        D: Pixel,
        D::Chan: From<Self::Chan>
, { ... } fn copy_color(dst: &mut [Self], clr: &Self) { ... } fn copy_slice(dst: &mut [Self], src: &[Self]) { ... } fn composite_color<O>(dst: &mut [Self], clr: &Self, op: O)
    where
        Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
        O: Blend
, { ... } fn composite_matte<M, O>(dst: &mut [Self], src: &[M], clr: &Self, op: O)
    where
        Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
        M: Pixel<Chan = Self::Chan, Model = Matte, Gamma = Linear>,
        O: Blend
, { ... } fn composite_slice<O>(dst: &mut [Self], src: &[Self], op: O)
    where
        Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
        O: Blend
, { ... } fn composite_channels<O>(&mut self, src: &Self, op: O)
    where
        Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
        O: Blend
, { ... } fn composite_channels_alpha<O>(
        &mut self,
        src: &Self,
        op: O,
        alpha: &Self::Chan
    )
    where
        Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
        O: Blend
, { ... }
}
Expand description

Pixel channel, color model, alpha and gamma mode.

A pixel can be converted to another format using the convert method.

Type Alias Naming Scheme

This trait is sealed, and cannot be implemented outside of this crate.

Required Associated Types

Channel type

Color model

Alpha mode

Gamma mode

Required Methods

Make a pixel from a slice of channels.

Convert from a pixel with a different bit depth.

Get the channels.

Get the channels mutably.

Provided Methods

Get the first channel.

Get a mutable reference to the first channel

Get the second channel.

Get a mutable reference to the second channel

Get the third channel.

Get a mutable reference to the third channel

Get the fourth channel.

Get a mutable reference to the fourth channel

Get the alpha channel.

Example: Get Alpha
use pix::chan::Ch16;
use pix::el::Pixel;
use pix::gray::Graya16;

let p = Graya16::new(0x7090, 0x6010);
assert_eq!(p.alpha(), Ch16::new(0x6010));

Get a mutable reference to the alpha channel.

Panics

Panics if the pixel does not contain an alpha channel.

Example: Set Alpha
use pix::chan::Ch8;
use pix::el::Pixel;
use pix::rgb::Rgba8;

let mut p = Rgba8::new(0xFF, 0x40, 0x80, 0xA5);
*p.alpha_mut() = Ch8::new(0x4B);
assert_eq!(p.alpha(), Ch8::new(0x4B));

Convert a pixel to another format

  • D Destination format.

Copy a color to a pixel slice

Copy a slice to another

Composite a color with a pixel slice

Composite matte with color to destination pixel slice

Composite two slices of pixels

Composite the channels of two pixels

Composite the channels of two pixels with alpha

Implementors