pub struct CustomPrimaries { /* private fields */ }Expand description
Validated custom tristimulus RGB primaries + white point (ICC cicpType amendment,
JXL, OpenEXR, PNG cHRM, HAGC Mode 3 / SMPTE ST 2094-50).
Implementations§
Source§impl CustomPrimaries
impl CustomPrimaries
Sourcepub const ACES_AP0: CustomPrimaries
pub const ACES_AP0: CustomPrimaries
ACES2065-1 (SMPTE ST 2065-1) AP0 primaries with D60 white point (negative y_B = -0.0770).
Sourcepub const ACES_CG: CustomPrimaries
pub const ACES_CG: CustomPrimaries
ACEScg (Academy S-2014-004) AP1 primaries with D60 white point.
Sourcepub const PROPHOTO_RGB: CustomPrimaries
pub const PROPHOTO_RGB: CustomPrimaries
ProPhoto RGB / ROMM RGB (ISO 22028-2) primaries with D50 white point.
Sourcepub const fn new(
r: (f32, f32),
g: (f32, f32),
b: (f32, f32),
white: (f32, f32),
) -> Option<CustomPrimaries>
pub const fn new( r: (f32, f32), g: (f32, f32), b: (f32, f32), white: (f32, f32), ) -> Option<CustomPrimaries>
Construct validated custom primaries, verifying a physical white point
(x > 0, y > 0, x + y < 1), valid primary coordinates (including imaginary
primaries such as ACES2065-1 AP0), and a finite, non-singular RGB → XYZ matrix.
Sourcepub const fn from_s15fixed16(coords: [i32; 8]) -> Option<CustomPrimaries>
pub const fn from_s15fixed16(coords: [i32; 8]) -> Option<CustomPrimaries>
Construct validated custom primaries from eight ICC s15Fixed16Number values
in the canonical field order [xR, yR, xG, yG, xB, yB, xw, yw] (ICC.1:2022 §10.3
cicpType amendment Table 32 / HAGC Mode 3 / SMPTE ST 2094-50).
Sourcepub const fn to_s15fixed16(self) -> [i32; 8]
pub const fn to_s15fixed16(self) -> [i32; 8]
Encode as eight ICC s15Fixed16Number values [xR, yR, xG, yG, xB, yB, xw, yw].
Sourcepub const fn from_cicp_extension_bytes(
bytes: [u8; 32],
) -> Option<CustomPrimaries>
pub const fn from_cicp_extension_bytes( bytes: [u8; 32], ) -> Option<CustomPrimaries>
Decode the 32-byte big-endian cicpType custom-primaries extension (ICC.1 §10.3
bytes 12..44, eight s15Fixed16Number values [xR, yR, xG, yG, xB, yB, xw, yw]).
Sourcepub const fn to_cicp_extension_bytes(self) -> [u8; 32]
pub const fn to_cicp_extension_bytes(self) -> [u8; 32]
Encode the 32-byte big-endian cicpType custom-primaries extension (ICC.1 §10.3
bytes 12..44).
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 (A1.1–A1.4) using Bradford chromatic adaptation to
the ICC PCS adopted white (0.9642, 1.0000, 0.8249) (ICC.1:2022 §7.2.16).
Columns 0, 1, 2 ([m[0][c], m[1][c], m[2][c]]) are the conforming
redMatrixColumnTag, greenMatrixColumnTag, and blueMatrixColumnTag XYZ triples.
Supports negative chromaticities such as ACES AP0 (y_B = -0.0770) without special cases.
Sourcepub const fn red(self) -> Chromaticity
pub const fn red(self) -> Chromaticity
Red primary (x, y).
Sourcepub const fn green(self) -> Chromaticity
pub const fn green(self) -> Chromaticity
Green primary (x, y).
Sourcepub const fn blue(self) -> Chromaticity
pub const fn blue(self) -> Chromaticity
Blue primary (x, y).
Sourcepub const fn white_point(self) -> Chromaticity
pub const fn white_point(self) -> Chromaticity
White point (x, y).
Sourcepub const fn chromaticity(self) -> ((f32, f32), (f32, f32), (f32, f32))
pub const fn chromaticity(self) -> ((f32, f32), (f32, f32), (f32, f32))
CIE 1931 (x, y) coordinates of (R, G, B) primaries.
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 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 RGB→XYZ Y row.
Sourcepub const fn luma_weights(self) -> [f32; 3]
pub const fn luma_weights(self) -> [f32; 3]
Linear-light luminance weights [Yr, Yg, Yb] (BT.709 fallback only if degenerate).
Sourcepub const fn same_chromaticity(self, other: CustomPrimaries) -> bool
pub const fn same_chromaticity(self, other: CustomPrimaries) -> bool
Whether self and other have bit-exact identical CIE 1931 primaries and white point.
Sourcepub const fn gamut_matrix_to(
self,
dst: CustomPrimaries,
) -> Option<[[f32; 3]; 3]>
pub const fn gamut_matrix_to( self, dst: CustomPrimaries, ) -> 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().
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).
Trait Implementations§
Source§impl Clone for CustomPrimaries
impl Clone for CustomPrimaries
Source§fn clone(&self) -> CustomPrimaries
fn clone(&self) -> CustomPrimaries
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more