Trait image::Pixel [] [src]

pub trait Pixel: Copy + Clone {
    type Subpixel: Primitive;
    fn channel_count() -> u8;
fn channels(&self) -> &[Self::Subpixel];
fn channels_mut(&mut self) -> &mut [Self::Subpixel];
fn color_model() -> &'static str;
fn color_type() -> ColorType;
fn channels4(
        &self
    ) -> (Self::Subpixel, Self::Subpixel, Self::Subpixel, Self::Subpixel);
fn from_channels(
        a: Self::Subpixel,
        b: Self::Subpixel,
        c: Self::Subpixel,
        d: Self::Subpixel
    ) -> Self;
fn from_slice(slice: &[Self::Subpixel]) -> &Self;
fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self;
fn to_rgb(&self) -> Rgb<Self::Subpixel>;
fn to_rgba(&self) -> Rgba<Self::Subpixel>;
fn to_luma(&self) -> Luma<Self::Subpixel>;
fn to_luma_alpha(&self) -> LumaA<Self::Subpixel>;
fn map<F>(&self, f: F) -> Self
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel
;
fn apply<F>(&mut self, f: F)
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel
;
fn map_with_alpha<F, G>(&self, f: F, g: G) -> Self
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel,
        G: FnMut(Self::Subpixel) -> Self::Subpixel
;
fn apply_with_alpha<F, G>(&mut self, f: F, g: G)
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel,
        G: FnMut(Self::Subpixel) -> Self::Subpixel
;
fn map2<F>(&self, other: &Self, f: F) -> Self
    where
        F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel
;
fn apply2<F>(&mut self, other: &Self, f: F)
    where
        F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel
;
fn invert(&mut self);
fn blend(&mut self, other: &Self); }

A generalized pixel.

A pixel object is usually not used standalone but as a view into an image buffer.

Associated Types

The underlying subpixel type.

Required Methods

Returns the number of channels of this pixel type.

Returns the components as a slice.

Returns the components as a mutable slice

Returns a string that can help to interpret the meaning each channel See gimp babl.

Returns the ColorType for this pixel format

Returns the channels of this pixel as a 4 tuple. If the pixel has less than 4 channels the remainder is filled with the maximum value

TODO deprecate

Construct a pixel from the 4 channels a, b, c and d. If the pixel does not contain 4 channels the extra are ignored.

TODO deprecate

Returns a view into a slice.

Note: The slice length is not checked on creation. Thus the caller has to ensure that the slice is long enough to present panics if the pixel is used later on.

Returns mutable view into a mutable slice.

Note: The slice length is not checked on creation. Thus the caller has to ensure that the slice is long enough to present panics if the pixel is used later on.

Convert this pixel to RGB

Convert this pixel to RGB with an alpha channel

Convert this pixel to luma

Convert this pixel to luma with an alpha channel

Apply the function f to each channel of this pixel.

Apply the function f to each channel of this pixel.

Apply the function f to each channel except the alpha channel. Apply the function g to the alpha channel.

Apply the function f to each channel except the alpha channel. Apply the function g to the alpha channel. Works in-place.

Apply the function f to each channel of this pixel and other pairwise.

Apply the function f to each channel of this pixel and other pairwise. Works in-place.

Invert this pixel

Blend the color of a given pixel into ourself, taking into account alpha channels

Implementors