#[non_exhaustive]pub enum ColorSpace {
DeviceGray,
DeviceRgb,
DeviceCmyk,
CalGray(Box<CalGray>),
CalRgb(Box<CalRgb>),
Lab(Box<Lab>),
IccBased(Box<IccBased>),
Indexed(Box<Indexed>),
Separation(Box<Separation>),
DeviceN(Box<DeviceN>),
Pattern(Box<PatternSpace>),
}Expand description
A loaded colour space.
Cheap to clone: the heavy members — ICC profiles, tint transforms — are
behind Arc, and palettes are boxed slices.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DeviceGray
One component: a grey level.
DeviceRgb
Three components: red, green, blue.
DeviceCmyk
Four components: cyan, magenta, yellow, black.
CalGray(Box<CalGray>)
A calibrated grey space whose calibration is parsed and then ignored.
CalRgb(Box<CalRgb>)
A calibrated RGB space.
Lab(Box<Lab>)
A CIE 1976 L*a*b* space.
IccBased(Box<IccBased>)
A space defined by an embedded ICC profile.
Indexed(Box<Indexed>)
A palette over some base space.
Separation(Box<Separation>)
One colorant driving an alternate space through a tint transform.
DeviceN(Box<DeviceN>)
Several colorants driving an alternate space.
Pattern(Box<PatternSpace>)
Colour supplied by a pattern rather than by components.
Implementations§
Source§impl ColorSpace
impl ColorSpace
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
How many components a colour in this space carries.
Separation and Indexed always report 1; ICCBased reports its
/N rather than whatever the profile says; DeviceN reports its
colorant count with no cap.
Sourcepub fn is_special(&self) -> bool
pub fn is_special(&self) -> bool
Whether the space’s components are indices or tints rather than
colour: Separation, DeviceN, Indexed, Pattern.
Several validation paths refuse a special space where a colour is
required — a shading’s alternate, an ICCBased’s /Alternate.
Sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
Whether the space is a plain additive or subtractive colour space, which decides whether a soft mask may take its backdrop from it.
Sourcepub fn to_rgb(&self, comps: &[f32]) -> Rgb
pub fn to_rgb(&self, comps: &[f32]) -> Rgb
Convert components to RGB, taking the vector-fill path.
A space that cannot produce a colour for these components — an out of
range Indexed entry, a /None Separation — paints black,
which is what every caller of the C++’s GetRGBOrZerosOnError sees.
Use Self::try_to_rgb when the distinction matters.
Sourcepub fn try_to_rgb(&self, comps: &[f32]) -> Option<Rgb>
pub fn try_to_rgb(&self, comps: &[f32]) -> Option<Rgb>
Convert components, distinguishing “black” from “no colour at all”.
Sourcepub fn default_value(&self, index: usize) -> (f32, f32, f32)
pub fn default_value(&self, index: usize) -> (f32, f32, f32)
The initial value and legal interval of component index.
The initial colour of a space is these values for each component:
zero everywhere except Separation and DeviceN, which start at full
colorant.
Sourcepub fn default_color(&self) -> Vec<f32>
pub fn default_color(&self) -> Vec<f32>
The space’s initial colour: one Self::default_value per component.
Sourcepub fn translate_image_line(
&self,
dest: &mut [u8],
samples: &[u8],
pixels: usize,
trans_mask: bool,
)
pub fn translate_image_line( &self, dest: &mut [u8], samples: &[u8], pixels: usize, trans_mask: bool, )
Convert a run of image samples to B, G, R triples.
This is the bulk path, and it is not to_rgb in a loop for every
family — see the module docs. samples holds pixels * n_components() bytes; dest receives pixels * 3.
trans_mask selects DeviceCMYK’s second formula, the one that is
unreachable from the scalar path; every other family ignores it.
Trait Implementations§
Source§impl Clone for ColorSpace
impl Clone for ColorSpace
Source§fn clone(&self) -> ColorSpace
fn clone(&self) -> ColorSpace
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more