Skip to main content

CustomPrimaries

Struct CustomPrimaries 

Source
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

Source

pub const ACES_AP0: CustomPrimaries

ACES2065-1 (SMPTE ST 2065-1) AP0 primaries with D60 white point (negative y_B = -0.0770).

Source

pub const ACES_CG: CustomPrimaries

ACEScg (Academy S-2014-004) AP1 primaries with D60 white point.

Source

pub const PROPHOTO_RGB: CustomPrimaries

ProPhoto RGB / ROMM RGB (ISO 22028-2) primaries with D50 white point.

Source

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.

Source

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).

Source

pub const fn to_s15fixed16(self) -> [i32; 8]

Encode as eight ICC s15Fixed16Number values [xR, yR, xG, yG, xB, yB, xw, yw].

Source

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]).

Source

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).

Source

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.

Source

pub const fn red(self) -> Chromaticity

Red primary (x, y).

Source

pub const fn green(self) -> Chromaticity

Green primary (x, y).

Source

pub const fn blue(self) -> Chromaticity

Blue primary (x, y).

Source

pub const fn white_point(self) -> Chromaticity

White point (x, y).

Source

pub const fn chromaticity(self) -> ((f32, f32), (f32, f32), (f32, f32))

CIE 1931 (x, y) coordinates of (R, G, B) primaries.

Source

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.

Source

pub const fn try_luma_weights(self) -> Option<[f32; 3]>

Linear-light luminance weights [Yr, Yg, Yb] derived from the RGB→XYZ Y row.

Source

pub const fn luma_weights(self) -> [f32; 3]

Linear-light luminance weights [Yr, Yg, Yb] (BT.709 fallback only if degenerate).

Source

pub const fn same_chromaticity(self, other: CustomPrimaries) -> bool

Whether self and other have bit-exact identical CIE 1931 primaries and white point.

Source

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().

Source

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.

Source

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

Source§

fn clone(&self) -> CustomPrimaries

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for CustomPrimaries

Source§

impl Debug for CustomPrimaries

Source§

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

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

impl Eq for CustomPrimaries

Source§

impl Hash for CustomPrimaries

Source§

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

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 CustomPrimaries

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CustomPrimaries

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<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.