Expand description
Represents an RGB pixel.
Fields§
§r: u8The red component of the pixel.
g: u8The green component of the pixel.
b: u8The blue component of the pixel.
Implementations§
source§impl Rgb
impl Rgb
Trait Implementations§
source§impl From<PalettedRgb<'_>> for Rgb
impl From<PalettedRgb<'_>> for Rgb
source§fn from(pixel: PalettedRgb<'_>) -> Rgb
fn from(pixel: PalettedRgb<'_>) -> Rgb
Converts to this type from the input type.
source§impl From<PalettedRgba<'_>> for Rgb
impl From<PalettedRgba<'_>> for Rgb
source§fn from(pixel: PalettedRgba<'_>) -> Rgb
fn from(pixel: PalettedRgba<'_>) -> Rgb
Converts to this type from the input type.
source§impl Pixel for Rgb
impl Pixel for Rgb
source§const COLOR_TYPE: ColorType = ColorType::Rgb
const COLOR_TYPE: ColorType = ColorType::Rgb
The color type of the pixel.
source§fn map_subpixels<F, A>(self, f: F, _: A) -> Rgbwhere
F: Fn(<Rgb as Pixel>::Subpixel) -> <Rgb as Pixel>::Subpixel,
A: Fn(<Rgb as Pixel>::Subpixel) -> <Rgb as Pixel>::Subpixel,
fn map_subpixels<F, A>(self, f: F, _: A) -> Rgbwhere
F: Fn(<Rgb as Pixel>::Subpixel) -> <Rgb as Pixel>::Subpixel,
A: Fn(<Rgb as Pixel>::Subpixel) -> <Rgb as Pixel>::Subpixel,
Maps the pixel’s components and returns a new pixel with the mapped components. Read more
source§fn from_raw_parts_paletted<P>(
color_type: ColorType,
bit_depth: u8,
data: &[u8],
palette: Option<&[P]>
) -> Result<Rgb, Error>where
P: Pixel,
fn from_raw_parts_paletted<P>(
color_type: ColorType,
bit_depth: u8,
data: &[u8],
palette: Option<&[P]>
) -> Result<Rgb, Error>where
P: Pixel,
Creates this pixel from the given color type, bit depth, data, and possibly a color palette.
This may require a lossy xonversion. Read more
source§fn from_bytes(bytes: &[u8]) -> Rgb
fn from_bytes(bytes: &[u8]) -> Rgb
Creates this pixel from a raw bytes. This is used internally and is unchecked - it panics
if the data is not of the correct length.
source§fn merge_with_alpha(self, other: Rgb, alpha: u8) -> Rgb
fn merge_with_alpha(self, other: Rgb, alpha: u8) -> Rgb
Merges this pixel with the given overlay pixel, where the alpha of the overlay pixel is
known. This is used in anti-aliasing.
source§fn from_dynamic(dynamic: Dynamic) -> Rgb
fn from_dynamic(dynamic: Dynamic) -> Rgb
Creates this pixel from any dynamic pixel, dynamically at runtime. Different from the
From/Into traits.
source§fn as_rgb(&self) -> Rgb
fn as_rgb(&self) -> Rgb
Returns this pixel as RGB despite its type. This can panic on some pixel types, you must
be sure this pixel is able to be converted into RGB before using this. Read more
source§fn as_rgba(&self) -> Rgba
fn as_rgba(&self) -> Rgba
Returns this pixel as RGBA despite its type. This can panic on some pixel types, you must
be sure this pixel is able to be converted into RGBA before using this. Read more
source§fn color_type(&self) -> ColorType
fn color_type(&self) -> ColorType
Resolves the color type of this pixel at runtime. This is used for dynamic color types.
If you are certain the pixel is not dynamic, you can use the
Self::COLOR_TYPE constant
instead.source§fn from_raw_parts(
color_type: ColorType,
bit_depth: u8,
data: &[u8]
) -> Result<Self, Error>
fn from_raw_parts(
color_type: ColorType,
bit_depth: u8,
data: &[u8]
) -> Result<Self, Error>
Creates this pixel from the given color type, bit depth, and data. This may require a lossy
conversion. Read more
source§fn from_arbitrary_palette<P>(palette: &[P], index: usize) -> Result<Self, Error>where
P: Pixel,
fn from_arbitrary_palette<P>(palette: &[P], index: usize) -> Result<Self, Error>where
P: Pixel,
Creates this pixel from the given palette and index, but the conversion is done at runtime. Read more
source§fn merge(self, other: Self) -> Self
fn merge(self, other: Self) -> Self
Merges this pixel with the given overlay pixel, taking into account alpha.
source§fn overlay(self, other: Self, mode: OverlayMode) -> Self
fn overlay(self, other: Self, mode: OverlayMode) -> Self
Overlays this pixel with the given overlay pixel, abiding by the given overlay mode.
source§fn overlay_with_alpha(self, other: Self, mode: OverlayMode, alpha: u8) -> Self
fn overlay_with_alpha(self, other: Self, mode: OverlayMode, alpha: u8) -> Self
Overlays this pixel with the given overlay pixel, abiding by the given overlay mode with
the given alpha. Read more