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 // Required 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]; // Provided methods 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§

source

type Chan: Channel

Channel type

source

type Model: ColorModel

Color model

source

type Alpha: Alpha

Alpha mode

source

type Gamma: Gamma

Gamma mode

Required Methods§

source

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

Make a pixel from a slice of channels.

source

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

Convert from a pixel with a different bit depth.

source

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

Get the channels.

source

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

Get the channels mutably.

Provided Methods§

source

fn one(self) -> Self::Chan

Get the first channel.

source

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

Get a mutable reference to the first channel

source

fn two(self) -> Self::Chan

Get the second channel.

source

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

Get a mutable reference to the second channel

source

fn three(self) -> Self::Chan

Get the third channel.

source

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

Get a mutable reference to the third channel

source

fn four(self) -> Self::Chan

Get the fourth channel.

source

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

Get a mutable reference to the fourth channel

source

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

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

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

Convert a pixel to another format

  • D Destination format.
source

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

Copy a color to a pixel slice

source

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

Copy a slice to another

source

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

source

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

source

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

source

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

source

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

Implementors§

source§

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

§

type Chan = C

§

type Model = M

§

type Alpha = A

§

type Gamma = G

source§

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

§

type Chan = C

§

type Model = M

§

type Alpha = A

§

type Gamma = G

source§

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

§

type Chan = C

§

type Model = M

§

type Alpha = A

§

type Gamma = G

source§

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

§

type Chan = C

§

type Model = M

§

type Alpha = A

§

type Gamma = G