#[non_exhaustive]pub enum Primaries {
Show 13 variants
Bt709,
Bt470M,
Bt470Bg,
Bt601,
Smpte240M,
GenericFilm,
Bt2020,
Xyz,
DciP3,
DisplayP3,
Ebu3213,
AdobeRgb,
Unknown,
}Expand description
Full re-export of zenpixels core types (zero module name collisions!).
Standardized 1-byte Copy + const chromaticity primaries (and reference white point) for
tristimulus RGB color spaces.
Covers all 11 standardized ITU-T H.273 Table 2 ColourPrimaries codes losslessly
(Primaries::from_cicp(cp)?.to_cicp() == Some(cp)), plus Adobe RGB (1998) and Unknown.
Arbitrary custom chromaticities (PNG cHRM, OpenEXR, JXL custom primaries, ACES AP0/AP1)
live in ColorSpace::RgbCustom via Arc<CustomPrimaries> so Primaries stays 1 byte,
ColorSpace stays 32 B.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bt709
ITU-R BT.709 / sRGB primaries, D65 white (CICP 1).
Bt470M
ITU-R BT.470-6 System M (NTSC 1953) primaries, Illuminant C white (0.310, 0.316) (CICP 4).
Bt470Bg
ITU-R BT.470-6 System B, G (PAL/SECAM) primaries, D65 white (CICP 5).
Bt601
ITU-R BT.601-7 525 / SMPTE 170M primaries, D65 white (CICP 6).
Smpte240M
SMPTE 240M primaries, D65 white (CICP 7; identical chromaticities to Self::Bt601, distinct code).
GenericFilm
Generic film (colour filters using Illuminant C), Illuminant C white (0.310, 0.316) (CICP 8).
Bt2020
ITU-R BT.2020 / BT.2100 wide-gamut primaries, D65 white (CICP 9).
Xyz
SMPTE ST 428-1 CIE 1931 XYZ primaries (R=(1,0), G=(0,1), B=(0,0)), Equal-Energy E white (CICP 10).
DciP3
SMPTE RP 431-2 DCI-P3 theater primaries, DCI white (0.314, 0.351) (CICP 11).
DisplayP3
Apple Display P3 / SMPTE EG 432-1 primaries, D65 white (CICP 12).
Ebu3213
EBU Tech. 3213-E / JEDEC P22 phosphors, D65 white (CICP 22).
AdobeRgb
Adobe RGB (1998) primaries, D65 white (no standard H.273 code).
Unknown
Unspecified / unknown primaries.
Implementations§
Source§impl Primaries
impl Primaries
Sourcepub const WHITE_C: (f32, f32)
pub const WHITE_C: (f32, f32)
CIE Standard Illuminant C white point (x, y) (BT.470M / Generic Film).
Sourcepub const WHITE_E: (f32, f32)
pub const WHITE_E: (f32, f32)
CIE Equal-Energy Illuminant E white point (x, y) (SMPTE ST 428-1 XYZ).
Sourcepub const fn chromaticity(self) -> Option<((f32, f32), (f32, f32), (f32, f32))>
pub const fn chromaticity(self) -> Option<((f32, f32), (f32, f32), (f32, f32))>
CIE 1931 (x, y) coordinates of (R, G, B) primaries, or None for Self::Unknown.
Sourcepub const fn white_point(self) -> Option<(f32, f32)>
pub const fn white_point(self) -> Option<(f32, f32)>
Reference white point (x, y) of these primaries, or None for Self::Unknown.
Sourcepub const fn to_custom(self) -> Option<CustomPrimaries>
pub const fn to_custom(self) -> Option<CustomPrimaries>
Convert any known Primaries variant (including named presets such as
Self::AdobeRgb and Self::Bt709) into explicit CustomPrimaries,
or None for Self::Unknown.
Sourcepub const fn to_icc_d50_matrix_f64(self) -> Option<[[f64; 3]; 3]>
pub const fn to_icc_d50_matrix_f64(self) -> Option<[[f64; 3]; 3]>
Derive the ICC PCS D50-adapted 3×3 primary matrix (M_D50 = M_adapt · M_native) per
ICC.1 cicpType Amendment Annex 1 using Bradford adaptation to PCS D50
(0.9642, 1.0000, 0.8249) (ICC.1:2022 §7.2.16).
Columns 0, 1, 2 are the rXYZ, gXYZ, bXYZ matrix column tags.
Sourcepub const fn same_chromaticity(self, other: Primaries) -> bool
pub const fn same_chromaticity(self, other: Primaries) -> bool
Whether self and other have identical CIE 1931 primaries and white point
(for example Self::Bt601 and Self::Smpte240M). Returns false if either side
is Self::Unknown unless both are Unknown.
Sourcepub const fn from_cicp(code: u8) -> Option<Primaries>
pub const fn from_cicp(code: u8) -> Option<Primaries>
Map an ITU-T H.273 Table 2 ColourPrimaries code to Primaries.
Lossless across all 11 standardized codes (1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22).
Sourcepub const fn to_cicp(self) -> Option<u8>
pub const fn to_cicp(self) -> Option<u8>
Map Primaries to an ITU-T H.273 Table 2 ColourPrimaries code, when standardized.
Sourcepub const fn try_luma_weights(self) -> Option<[f32; 3]>
pub const fn try_luma_weights(self) -> Option<[f32; 3]>
Linear-light luminance weights [Yr, Yg, Yb] derived from the primaries’ RGB→XYZ Y row,
or None for Self::Unknown (use Self::luma_weights only when a BT.709 fallback is intended).
Sourcepub const fn luma_weights(self) -> [f32; 3]
pub const fn luma_weights(self) -> [f32; 3]
Linear-light luminance weights [Yr, Yg, Yb] derived from the primaries’ RGB→XYZ Y row
(falls back to BT.709 for Self::Unknown; prefer try_luma_weights
when unknown primaries must be refused).
Sourcepub const fn rgb_to_xyz_f64(self) -> Option<[[f64; 3]; 3]>
pub const fn rgb_to_xyz_f64(self) -> Option<[[f64; 3]; 3]>
Linear RGB → CIE XYZ (Y_white = 1.0, relative to self.white_point()) 3×3 matrix in f64.
Sourcepub const fn gamut_matrix_to(self, dst: Primaries) -> Option<[[f32; 3]; 3]>
pub const fn gamut_matrix_to(self, dst: Primaries) -> Option<[[f32; 3]; 3]>
Exact 3×3 linear-light gamut conversion matrix from self to dst, applying
Bradford chromatic adaptation automatically when self.white_point() != dst.white_point().
Returns the identity matrix when self == dst (for known primaries),
and None if either side is Self::Unknown.
Sourcepub const fn xyz_to_rgb_f32(
self,
src_white: WhitePoint,
) -> Option<[[f32; 3]; 3]>
pub const fn xyz_to_rgb_f32( self, src_white: WhitePoint, ) -> Option<[[f32; 3]; 3]>
Bradford-adapted 3×3 matrix converting CIE XYZ (at src_white) → linear RGB in self.
Sourcepub const fn rgb_to_xyz_f32(
self,
dst_white: WhitePoint,
) -> Option<[[f32; 3]; 3]>
pub const fn rgb_to_xyz_f32( self, dst_white: WhitePoint, ) -> Option<[[f32; 3]; 3]>
Bradford-adapted 3×3 matrix converting linear RGB in self → CIE XYZ (at dst_white).