Trait cosmic::iced_winit::graphics::image::image_rs::Pixel

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

    const CHANNEL_COUNT: u8;
    const COLOR_MODEL: &'static str;
Show 20 methods // Required methods fn channels(&self) -> &[Self::Subpixel]; fn channels_mut(&mut self) -> &mut [Self::Subpixel]; 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); // Provided methods 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 { ... }
}
Expand description

A generalized pixel.

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

Required Associated Types§

source

type Subpixel: Primitive

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

Required Associated Constants§

source

const CHANNEL_COUNT: u8

The number of channels of this pixel type.

source

const COLOR_MODEL: &'static str

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

Required Methods§

source

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

Returns the components as a slice.

source

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

Returns the components as a mutable slice

source

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

👎Deprecated since 0.24.0: Use channels() or channels_mut()

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

source

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

👎Deprecated since 0.24.0: Use the constructor of the pixel, for example Rgba([r,g,b,a]) or Pixel::from_slice

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

source

fn from_slice(slice: &[Self::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.

source

fn from_slice_mut(slice: &mut [Self::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.

source

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

Convert this pixel to RGB

source

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

Convert this pixel to RGB with an alpha channel

source

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

Convert this pixel to luma

source

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

Convert this pixel to luma with an alpha channel

source

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

Apply the function f to each channel of this pixel.

source

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

Apply the function f to each channel of this pixel.

source

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,

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

source

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,

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

source

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

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

source

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

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

source

fn invert(&mut self)

Invert this pixel

source

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

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

Provided Methods§

source

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

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

source

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

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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> Pixel for Luma<T>
where T: Primitive,

source§

type Subpixel = T

source§

const CHANNEL_COUNT: u8 = 1u8

source§

const COLOR_MODEL: &'static str = "Y"

source§

impl<T> Pixel for LumaA<T>
where T: Primitive,

source§

type Subpixel = T

source§

const CHANNEL_COUNT: u8 = 2u8

source§

const COLOR_MODEL: &'static str = "YA"

source§

impl<T> Pixel for Rgb<T>
where T: Primitive + Enlargeable,

source§

type Subpixel = T

source§

const CHANNEL_COUNT: u8 = 3u8

source§

const COLOR_MODEL: &'static str = "RGB"

source§

impl<T> Pixel for Rgba<T>
where T: Primitive + Enlargeable,

source§

type Subpixel = T

source§

const CHANNEL_COUNT: u8 = 4u8

source§

const COLOR_MODEL: &'static str = "RGBA"