#[non_exhaustive]pub enum ColorProfileSource<'a> {
Icc(&'a [u8]),
Cicp(Cicp),
Named(NamedProfile),
PrimariesTransferPair {
primaries: ColorPrimaries,
transfer: TransferFunction,
},
}Expand description
A source color profile — either ICC bytes, CICP parameters, a named profile, or a primaries + transfer function pair.
This unified type lets consumers pass decoded image color info directly to a CMS backend without caring whether the source had an ICC profile, CICP codes, or a well-known named profile.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Icc(&'a [u8])
Raw ICC profile data.
Cicp(Cicp)
CICP parameters (a CMS can synthesize an equivalent profile).
Named(NamedProfile)
Well-known named profile.
PrimariesTransferPair
Color primaries + transfer function pair.
Covers the full ColorPrimaries × TransferFunction matrix,
including combinations that don’t have a NamedProfile variant
or a CICP mapping (e.g., Adobe RGB).
A CMS backend that handles this variant can avoid ICC profile parsing entirely for known primaries/transfer combinations.
Fields
primaries: ColorPrimariesColor primaries (gamut + white point).
transfer: TransferFunctionTransfer function (EOTF encoding).
Implementations§
Source§impl<'a> ColorProfileSource<'a>
impl<'a> ColorProfileSource<'a>
Sourcepub const fn from_primaries_transfer(
primaries: ColorPrimaries,
transfer: TransferFunction,
) -> ColorProfileSource<'a>
pub const fn from_primaries_transfer( primaries: ColorPrimaries, transfer: TransferFunction, ) -> ColorProfileSource<'a>
Create from primaries + transfer function.
Sourcepub const fn primaries_transfer(
&self,
) -> Option<(ColorPrimaries, TransferFunction)>
pub const fn primaries_transfer( &self, ) -> Option<(ColorPrimaries, TransferFunction)>
Try to extract primaries + transfer, regardless of variant.
PrimariesTransferPair— returns directlyNamed— decomposes viaNamedProfile::to_primaries_transferCicp— maps viaColorPrimaries::from_cicpandTransferFunction::from_cicpIcc— returnsNone(requires profile parsing)
Sourcepub fn resolve(&self) -> Option<(ColorPrimaries, TransferFunction)>
pub fn resolve(&self) -> Option<(ColorPrimaries, TransferFunction)>
Resolve to a (primaries, transfer) pair using all available methods,
including ICC profile identification when the icc feature is enabled.
This is the most complete resolution path:
PrimariesTransferPair— returns directlyNamed— decomposes viaNamedProfile::to_primaries_transferCicp— maps viafrom_cicp, but returnsNoneifmatrix_coefficientsis non-zero (YCbCr data requires matrix conversion first) orfull_rangeis false (narrow-range data needs range expansion first)Icc— hash-based identification (~100ns, 135 known profiles) + CICP-in-ICC extraction. ReturnsNonefor unknown custom profiles.
Returns None when the profile is unknown or when reducing to
(primaries, transfer) would discard significant information
(YCbCr matrix coefficients, narrow signal range).
Trait Implementations§
Source§impl<'a> Clone for ColorProfileSource<'a>
impl<'a> Clone for ColorProfileSource<'a>
Source§fn clone(&self) -> ColorProfileSource<'a>
fn clone(&self) -> ColorProfileSource<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more