[−][src]Trait pix::el::Pixel
Pixel channel, color model, alpha and gamma mode.
A pixel can be converted to another format using the convert method.
Type Alias Naming Scheme
- Gamma:
S
for sRGB gamma encoding; linear if omitted. - Color model:
Rgb
/Bgr
/Gray
/Cmy
/Hsv
/Hsl
/Hwb
/YCbCr
/Matte
. - Alpha:
a
to include alpha channel enabling translucent pixels. - Bit depth:
8
/16
/32
for 8-bit integer, 16-bit integer and 32-bit floating-point channels. - Alpha mode:
p
for premultiplied; straight if omitted.
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
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>,
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.
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>,
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,
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,
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,
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,
Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
O: Blend,
Composite the channels of two pixels
fn composite_channels_matte<O>(&mut self, alpha: &Self::Chan, src: &Self, op: O) where
Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
O: Blend,
Self: Pixel<Alpha = Premultiplied, Gamma = Linear>,
O: Blend,
Composite the channels of pixels with a matte and color
Implementors
impl<C, M, A, G> Pixel for Pix1<C, M, A, G> where
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
[src]
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
type Chan = C
type Model = M
type Alpha = A
type Gamma = G
fn from_channels(ch: &[C]) -> Self
[src]
fn from_bit_depth<P>(p: P) -> Self where
P: Pixel,
Self::Chan: From<P::Chan>,
[src]
P: Pixel,
Self::Chan: From<P::Chan>,
fn channels(&self) -> &[Self::Chan]
[src]
fn channels_mut(&mut self) -> &mut [Self::Chan]
[src]
impl<C, M, A, G> Pixel for Pix2<C, M, A, G> where
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
[src]
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
type Chan = C
type Model = M
type Alpha = A
type Gamma = G
fn from_channels(ch: &[C]) -> Self
[src]
fn from_bit_depth<P>(p: P) -> Self where
P: Pixel,
Self::Chan: From<P::Chan>,
[src]
P: Pixel,
Self::Chan: From<P::Chan>,
fn channels(&self) -> &[Self::Chan]
[src]
fn channels_mut(&mut self) -> &mut [Self::Chan]
[src]
impl<C, M, A, G> Pixel for Pix3<C, M, A, G> where
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
[src]
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
type Chan = C
type Model = M
type Alpha = A
type Gamma = G
fn from_channels(ch: &[C]) -> Self
[src]
fn from_bit_depth<P>(p: P) -> Self where
P: Pixel,
Self::Chan: From<P::Chan>,
[src]
P: Pixel,
Self::Chan: From<P::Chan>,
fn channels(&self) -> &[Self::Chan]
[src]
fn channels_mut(&mut self) -> &mut [Self::Chan]
[src]
impl<C, M, A, G> Pixel for Pix4<C, M, A, G> where
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,
[src]
C: Channel,
M: ColorModel,
A: Alpha,
G: Gamma,