Trait Pixel

trait Pixel: Copy + Clone

A generalized pixel.

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

Associated Types

type Subpixel: TraitBound { trait_: Path { path: "Primitive", id: Id(476), args: None }, generic_params: [], modifier: None }

The scalar type that is used to store each channel in this pixel.

Required Methods

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

Returns the components as a slice.

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

Returns the components as a mutable slice

fn channels4(self: &Self) -> (<Self as >::Subpixel, <Self as >::Subpixel, <Self as >::Subpixel, <Self as >::Subpixel)

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

fn from_channels(a: <Self as >::Subpixel, b: <Self as >::Subpixel, c: <Self as >::Subpixel, d: <Self as >::Subpixel) -> Self

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

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

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 as >::Subpixel]) -> &mut Self

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: &Self) -> Rgb<<Self as >::Subpixel>

Convert this pixel to RGB

fn to_rgba(self: &Self) -> Rgba<<Self as >::Subpixel>

Convert this pixel to RGB with an alpha channel

fn to_luma(self: &Self) -> Luma<<Self as >::Subpixel>

Convert this pixel to luma

fn to_luma_alpha(self: &Self) -> LumaA<<Self as >::Subpixel>

Convert this pixel to luma with an alpha channel

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

Apply the function f to each channel of this pixel.

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

Apply the function f to each channel of this pixel.

fn map_with_alpha<F, G>(self: &Self, f: F, g: G) -> Self
where
    F: FnMut(<Self as >::Subpixel) -> <Self as >::Subpixel,
    G: FnMut(<Self as >::Subpixel) -> <Self as >::Subpixel

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>(self: &mut Self, f: F, g: G)
where
    F: FnMut(<Self as >::Subpixel) -> <Self as >::Subpixel,
    G: FnMut(<Self as >::Subpixel) -> <Self as >::Subpixel

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: &Self, other: &Self, f: F) -> Self
where
    F: FnMut(<Self as >::Subpixel, <Self as >::Subpixel) -> <Self as >::Subpixel

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

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

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

fn invert(self: &mut Self)

Invert this pixel

fn blend(self: &mut Self, other: &Self)

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

Provided Methods

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

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

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

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

Implementors