[][src]Trait pix::el::Pixel

pub trait Pixel: Clone + Copy + Debug + Default + PartialEq + Sealed {
    type Chan: Channel;
    type Model: ColorModel;
    type Alpha: Alpha;
    type Gamma: Gamma;
    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
, { ... } }

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.

Associated Types

type Chan: Channel

Channel type

type Model: ColorModel

Color model

type Alpha: Alpha

Alpha mode

type Gamma: Gamma

Gamma mode

Loading content...

Required methods

fn from_channels(ch: &[Self::Chan]) -> Self

Make a pixel from a slice of channels.

fn from_bit_depth<P>(p: P) -> Self where
    P: Pixel,
    Self::Chan: From<P::Chan>, 

Convert from a pixel with a different bit depth.

fn channels(&self) -> &[Self::Chan]

Get the channels.

fn channels_mut(&mut self) -> &mut [Self::Chan]

Get the channels mutably.

Loading content...

Provided methods

fn one(self) -> Self::Chan

Get the first channel.

fn one_mut(&mut self) -> &mut Self::Chan

Get a mutable reference to the first channel

fn two(self) -> Self::Chan

Get the second channel.

fn two_mut(&mut self) -> &mut Self::Chan

Get a mutable reference to the second channel

fn three(self) -> Self::Chan

Get the third channel.

fn three_mut(&mut self) -> &mut Self::Chan

Get a mutable reference to the third channel

fn four(self) -> Self::Chan

Get the fourth channel.

fn four_mut(&mut self) -> &mut Self::Chan

Get a mutable reference to the fourth channel

fn alpha(self) -> Self::Chan

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));

fn alpha_mut(&mut self) -> &mut Self::Chan

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));

fn convert<D>(self) -> D where
    D: Pixel,
    D::Chan: From<Self::Chan>, 

Convert a pixel to another format

  • D Destination format.

fn copy_color(dst: &mut [Self], clr: &Self)

Copy a color to a pixel slice

fn copy_slice(dst: &mut [Self], src: &[Self])

Copy a slice to another

fn composite_color<O>(dst: &mut [Self], clr: &Self, op: O) where
    Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
    O: Blend

Composite a color with a pixel slice

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

Composite matte with color to destination pixel slice

fn composite_slice<O>(dst: &mut [Self], src: &[Self], op: O) where
    Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
    O: Blend

Composite two slices of pixels

fn composite_channels<O>(&mut self, src: &Self, op: O) where
    Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
    O: Blend

Composite the channels of two pixels

fn composite_channels_alpha<O>(&mut self, src: &Self, op: O, alpha: &Self::Chan) where
    Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
    O: Blend

Composite the channels of two pixels with alpha

Loading content...

Implementors

impl<C, M, A, G> Pixel for Pix1<C, M, A, G> where
    C: Channel,
    M: ColorModel,
    A: Alpha,
    G: Gamma
[src]

type Chan = C

type Model = M

type Alpha = A

type Gamma = G

impl<C, M, A, G> Pixel for Pix2<C, M, A, G> where
    C: Channel,
    M: ColorModel,
    A: Alpha,
    G: Gamma
[src]

type Chan = C

type Model = M

type Alpha = A

type Gamma = G

impl<C, M, A, G> Pixel for Pix3<C, M, A, G> where
    C: Channel,
    M: ColorModel,
    A: Alpha,
    G: Gamma
[src]

type Chan = C

type Model = M

type Alpha = A

type Gamma = G

impl<C, M, A, G> Pixel for Pix4<C, M, A, G> where
    C: Channel,
    M: ColorModel,
    A: Alpha,
    G: Gamma
[src]

type Chan = C

type Model = M

type Alpha = A

type Gamma = G

Loading content...