pub enum ColorMode {
Show 13 variants
Rgb,
Rgba,
Bgr,
Bgra,
Argb,
Rgba4444,
Rgb565,
PremultipliedRgba,
PremultipliedBgra,
PremultipliedArgb,
PremultipliedRgba4444,
Yuv,
Yuva,
}Expand description
The layout of the decoded samples (C: WEBP_CSP_MODE, in its order).
Names give the byte order of a pixel; the Premultiplied modes multiply
red, green and blue by alpha.
§Examples
use webp::api::decode::ColorMode;
assert_eq!(ColorMode::Bgra.bytes_per_pixel(), Some(4));
assert_eq!(ColorMode::Rgb565.bytes_per_pixel(), Some(2));
assert_eq!(ColorMode::Yuva.bytes_per_pixel(), None);
assert!(ColorMode::PremultipliedArgb.is_premultiplied());Variants§
Rgb
Red, green, blue (C: MODE_RGB).
Rgba
Red, green, blue, straight alpha (C: MODE_RGBA).
Bgr
Blue, green, red (C: MODE_BGR).
Bgra
Blue, green, red, straight alpha (C: MODE_BGRA).
Argb
Straight alpha, red, green, blue (C: MODE_ARGB).
Rgba4444
Red and green, then blue and straight alpha, 4 bits each, in two bytes
(C: MODE_RGBA_4444).
Rgb565
Red (5 bits) and green (6 bits), then blue (5 bits), in two bytes
(C: MODE_RGB_565).
PremultipliedRgba
ColorMode::Rgba with premultiplied alpha (C: MODE_rgbA).
PremultipliedBgra
ColorMode::Bgra with premultiplied alpha (C: MODE_bgrA).
PremultipliedArgb
ColorMode::Argb with premultiplied alpha (C: MODE_Argb).
PremultipliedRgba4444
ColorMode::Rgba4444 with premultiplied alpha (C: MODE_rgbA_4444).
Yuv
Y, U and V planes, 4:2:0, limited range (C: MODE_YUV).
Yuva
Y, U, V and straight alpha planes (C: MODE_YUVA).
Implementations§
Source§impl ColorMode
impl ColorMode
Sourcepub const fn bytes_per_pixel(self) -> Option<usize>
pub const fn bytes_per_pixel(self) -> Option<usize>
The bytes of a pixel in the RGB modes (libwebp’s kModeBpp), or
None for the planar YUV modes.
§Examples
use webp::api::decode::ColorMode;
assert_eq!(ColorMode::Rgb.bytes_per_pixel(), Some(3));
assert_eq!(ColorMode::Yuv.bytes_per_pixel(), None);Sourcepub const fn has_alpha(self) -> bool
pub const fn has_alpha(self) -> bool
Whether the output holds alpha (C: WebPIsAlphaMode).
§Examples
use webp::api::decode::ColorMode;
assert!(ColorMode::Yuva.has_alpha());
assert!(!ColorMode::Rgb565.has_alpha());Sourcepub const fn is_premultiplied(self) -> bool
pub const fn is_premultiplied(self) -> bool
Whether red, green and blue are multiplied by alpha (C:
WebPIsPremultipliedMode).
§Examples
use webp::api::decode::ColorMode;
assert!(ColorMode::PremultipliedRgba4444.is_premultiplied());
assert!(!ColorMode::Rgba.is_premultiplied());Sourcepub const fn is_yuv(self) -> bool
pub const fn is_yuv(self) -> bool
Whether the output is planar Y'CbCr (ColorMode::Yuv,
ColorMode::Yuva) rather than packed RGB rows.
§Examples
use webp::api::decode::ColorMode;
assert!(ColorMode::Yuv.is_yuv());
assert!(!ColorMode::Argb.is_yuv());