skia_safe

Enum ColorType

Source
#[repr(i32)]
pub enum ColorType {
Show 27 variants Unknown = 0, Alpha8 = 1, RGB565 = 2, ARGB4444 = 3, RGBA8888 = 4, RGB888x = 5, BGRA8888 = 6, RGBA1010102 = 7, BGRA1010102 = 8, RGB101010x = 9, BGR101010x = 10, BGR101010xXR = 11, BGRA10101010XR = 12, RGBA10x6 = 13, Gray8 = 14, RGBAF16Norm = 15, RGBAF16 = 16, RGBF16F16F16x = 17, RGBAF32 = 18, R8G8UNorm = 19, A16Float = 20, R16G16Float = 21, A16UNorm = 22, R16G16UNorm = 23, R16G16B16A16UNorm = 24, SRGBA8888 = 25, R8UNorm = 26,
}
Expand description

Describes how pixel bits encode color. A pixel may be an alpha mask, a grayscale, RGB, or ARGB.

The names of each variant implicitly define the channel ordering and size in memory. Due to historical reasons the names do not follow 100% identical convention, but are typically labeled from least significant to most significant.

Unless specified otherwise, a channel’s value is treated as an unsigned integer with a range of [0, 2^N-1] and this is mapped uniformly to a floating point value of [0.0, 1.0]. Some color types instead store data directly in 32-bit floating point (assumed to be IEEE), or in 16-bit “half” floating point values.

Note: By default, Skia operates with the assumption of a little-Endian system. The bit patterns shown in the documentation assume LE byte order.

Variants§

§

Unknown = 0

Unknown or unrepresentable as an SkColorType.

§

Alpha8 = 1

Single channel data (8-bit) interpreted as an alpha value. RGB are 0. Bits: [A:7..0]

§

RGB565 = 2

Three channel BGR data (5 bits red, 6 bits green, 5 bits blue) packed into a LE 16-bit word. Bits: [R:15..11 G:10..5 B:4..0]

§

ARGB4444 = 3

Four channel ABGR data (4 bits per channel) packed into a LE 16-bit word. Bits: [R:15..12 G:11..8 B:7..4 A:3..0]

§

RGBA8888 = 4

Four channel RGBA data (8 bits per channel) packed into a LE 32-bit word. Bits: [A:31..24 B:23..16 G:15..8 R:7..0]

§

RGB888x = 5

Three channel RGB data (8 bits per channel) packed into a LE 32-bit word. The remaining bits are ignored and alpha is forced to opaque. Bits: [x:31..24 B:23..16 G:15..8 R:7..0]

§

BGRA8888 = 6

Four channel BGRA data (8 bits per channel) packed into a LE 32-bit word. R and B are swapped relative to RGBA8888. Bits: [A:31..24 R:23..16 G:15..8 B:7..0]

§

RGBA1010102 = 7

Four channel RGBA data (10 bits per color, 2 bits for alpha) packed into a LE 32-bit word. Bits: [A:31..30 B:29..20 G:19..10 R:9..0]

§

BGRA1010102 = 8

Four channel BGRA data (10 bits per color, 2 bits for alpha) packed into a LE 32-bit word. R and B are swapped relative to RGBA1010102. Bits: [A:31..30 R:29..20 G:19..10 B:9..0]

§

RGB101010x = 9

Three channel RGB data (10 bits per channel) packed into a LE 32-bit word. The remaining bits are ignored and alpha is forced to opaque. Bits: [x:31..30 B:29..20 G:19..10 R:9..0]

§

BGR101010x = 10

Three channel BGR data (10 bits per channel) packed into a LE 32-bit word. The remaining bits are ignored and alpha is forced to opaque. R and B are swapped relative to RGB101010x. Bits: [x:31..30 R:29..20 G:19..10 B:9..0]

§

BGR101010xXR = 11

Three channel BGR data (10 bits per channel) packed into a LE 32-bit word. The remaining bits are ignored and alpha is forced to opaque. Instead of normalizing [0, 1023] to [0.0, 1.0] the color channels map to an extended range of [-0.752941, 1.25098]. Bits: [x:31..30 R:29..20 G:19..10 B:9..0]

§

BGRA10101010XR = 12

Four channel BGRA data (10 bits per channel) packed into a LE 64-bit word. Each channel is preceded by 6 bits of padding. Instead of normalizing [0, 1023] to [0.0, 1.0] the color and alpha channels map to an extended range of [-0.752941, 1.25098]. Bits: [A:63..54 x:53..48 R:47..38 x:37..32 G:31..22 x:21..16 B:15..6 x:5..0]

§

RGBA10x6 = 13

Four channel RGBA data (10 bits per channel) packed into a LE 64-bit word. Each channel is preceded by 6 bits of padding. Bits: [A:63..54 x:53..48 B:47..38 x:37..32 G:31..22 x:21..16 R:15..6 x:5..0]

§

Gray8 = 14

Single channel data (8-bit) interpreted as a grayscale value (e.g. replicated to RGB). Bits: [G:7..0]

§

RGBAF16Norm = 15

Four channel RGBA data (16-bit half-float per channel) packed into a LE 64-bit word. Values are assumed to be in [0.0,1.0] range, unlike RGBAF16. Bits: [A:63..48 B:47..32 G:31..16 R:15..0]

§

RGBAF16 = 16

Four channel RGBA data (16-bit half-float per channel) packed into a LE 64-bit word. This has extended range compared to RGBAF16Norm. Bits: [A:63..48 B:47..32 G:31..16 R:15..0]

§

RGBF16F16F16x = 17

Three channel RGB data (16-bit half-float per channel) packed into a LE 64-bit word. The last 16 bits are ignored and alpha is forced to opaque. Bits: [x:63..48 B:47..32 G:31..16 R:15..0]

§

RGBAF32 = 18

Four channel RGBA data (32-bit float per channel) packed into a LE 128-bit word. Bits: [A:127..96 B:95..64 G:63..32 R:31..0]

§

R8G8UNorm = 19

Two channel RG data (8 bits per channel). Blue is forced to 0, alpha is forced to opaque. Bits: [G:15..8 R:7..0]

§

A16Float = 20

Single channel data (16-bit half-float) interpreted as alpha. RGB are 0. Bits: [A:15..0]

§

R16G16Float = 21

Two channel RG data (16-bit half-float per channel) packed into a LE 32-bit word. Blue is forced to 0, alpha is forced to opaque. Bits: [G:31..16 R:15..0]

§

A16UNorm = 22

Single channel data (16 bits) interpreted as alpha. RGB are 0. Bits: [A:15..0]

§

R16G16UNorm = 23

Two channel RG data (16 bits per channel) packed into a LE 32-bit word. B is forced to 0, alpha is forced to opaque. Bits: [G:31..16 R:15..0]

§

R16G16B16A16UNorm = 24

Four channel RGBA data (16 bits per channel) packed into a LE 64-bit word. Bits: [A:63..48 B:47..32 G:31..16 R:15..0]

§

SRGBA8888 = 25

Four channel RGBA data (8 bits per channel) packed into a LE 32-bit word. The RGB values are assumed to be encoded with the sRGB transfer function. Bits: [A:31..24 B:23..16 G:15..8 R:7..0]

§

R8UNorm = 26

Single channel data (8 bits) interpreted as red. G and B are forced to 0, alpha is forced to opaque. Bits: [R:7..0]

Implementations§

Source§

impl ColorType

Source

pub const N32: Self

Source

pub const COUNT: usize = 27usize

Source

pub const fn n32() -> Self

👎Deprecated since 0.51.0: Use ColorType::N32
Source

pub fn bytes_per_pixel(self) -> usize

Source

pub fn is_always_opaque(self) -> bool

Source

pub fn validate_alpha_type(self, alpha_type: AlphaType) -> Option<AlphaType>

Trait Implementations§

Source§

impl Clone for ColorType

Source§

fn clone(&self) -> ColorType

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ColorType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for ColorType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ColorType

Source§

fn eq(&self, other: &ColorType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ColorType

Source§

impl Eq for ColorType

Source§

impl StructuralPartialEq for ColorType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<N, T> NativeTransmutableWrapper<N> for T
where T: NativeTransmutable<N>,

Source§

fn wrap(native: N) -> T

Source§

fn unwrap(self) -> N

Source§

fn inner(&self) -> &N

Source§

fn inner_mut(&mut self) -> &mut N

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.