Trait image::Pixel[][src]

pub trait Pixel: Copy + Clone {
    type Subpixel: Primitive;

    const CHANNEL_COUNT: u8;
    const COLOR_MODEL: &'static str;
    const COLOR_TYPE: ColorType;
Show methods fn channels(&self) -> &[Self::Subpixel]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
;
fn channels_mut(&mut self) -> &mut [Self::Subpixel]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
;
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 to_bgr(&self) -> Bgr<Self::Subpixel>;
fn to_bgra(&self) -> Bgra<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); fn channel_count() -> u8 { ... }
fn color_model() -> &'static str { ... }
fn color_type() -> ColorType { ... }
fn map_without_alpha<F>(&self, f: F) -> Self
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel
, { ... }
fn apply_without_alpha<F>(&mut self, f: F)
    where
        F: FnMut(Self::Subpixel) -> Self::Subpixel
, { ... }
}

A generalized pixel.

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

Associated Types

type Subpixel: Primitive[src]

The underlying subpixel type.

Loading content...

Associated Constants

const CHANNEL_COUNT: u8[src]

The number of channels of this pixel type.

const COLOR_MODEL: &'static str[src]

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

const COLOR_TYPE: ColorType[src]

ColorType for this pixel format

Loading content...

Required methods

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Returns the components as a slice.

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

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Returns the components as a mutable slice

fn channels4(
    &self
) -> (Self::Subpixel, Self::Subpixel, Self::Subpixel, Self::Subpixel)
[src]

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

fn from_channels(
    a: Self::Subpixel,
    b: Self::Subpixel,
    c: Self::Subpixel,
    d: Self::Subpixel
) -> Self
[src]

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

fn from_slice(slice: &[Self::Subpixel]) -> &Self[src]

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 prevent panics if the pixel is used later on.

fn from_slice_mut(slice: &mut [Self::Subpixel]) -> &mut Self[src]

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 prevent panics if the pixel is used later on.

fn to_rgb(&self) -> Rgb<Self::Subpixel>[src]

Convert this pixel to RGB

fn to_rgba(&self) -> Rgba<Self::Subpixel>[src]

Convert this pixel to RGB with an alpha channel

fn to_luma(&self) -> Luma<Self::Subpixel>[src]

Convert this pixel to luma

fn to_luma_alpha(&self) -> LumaA<Self::Subpixel>[src]

Convert this pixel to luma with an alpha channel

fn to_bgr(&self) -> Bgr<Self::Subpixel>[src]

Convert this pixel to BGR

fn to_bgra(&self) -> Bgra<Self::Subpixel>[src]

Convert this pixel to BGR with an alpha channel

fn map<F>(&self, f: F) -> Self where
    F: FnMut(Self::Subpixel) -> Self::Subpixel
[src]

Apply the function f to each channel of this pixel.

fn apply<F>(&mut self, f: F) where
    F: FnMut(Self::Subpixel) -> Self::Subpixel
[src]

Apply the function f to each channel of this pixel.

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
[src]

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

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
[src]

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

fn map2<F>(&self, other: &Self, f: F) -> Self where
    F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel
[src]

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

fn apply2<F>(&mut self, other: &Self, f: F) where
    F: FnMut(Self::Subpixel, Self::Subpixel) -> Self::Subpixel
[src]

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

fn invert(&mut self)[src]

Invert this pixel

fn blend(&mut self, other: &Self)[src]

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

Loading content...

Provided methods

fn channel_count() -> u8[src]

👎 Deprecated:

please use CHANNEL_COUNT associated constant

Returns the number of channels of this pixel type.

fn color_model() -> &'static str[src]

👎 Deprecated:

please use COLOR_MODEL associated constant

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

fn color_type() -> ColorType[src]

👎 Deprecated:

please use COLOR_TYPE associated constant

Returns the ColorType for this pixel format

fn map_without_alpha<F>(&self, f: F) -> Self where
    F: FnMut(Self::Subpixel) -> Self::Subpixel
[src]

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

fn apply_without_alpha<F>(&mut self, f: F) where
    F: FnMut(Self::Subpixel) -> Self::Subpixel
[src]

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

Loading content...

Implementors

impl<T: Primitive + 'static> Pixel for Bgr<T>[src]

type Subpixel = T

impl<T: Primitive + 'static> Pixel for Bgra<T>[src]

type Subpixel = T

impl<T: Primitive + 'static> Pixel for Luma<T>[src]

type Subpixel = T

impl<T: Primitive + 'static> Pixel for LumaA<T>[src]

type Subpixel = T

impl<T: Primitive + 'static> Pixel for Rgb<T>[src]

type Subpixel = T

impl<T: Primitive + 'static> Pixel for Rgba<T>[src]

type Subpixel = T

Loading content...