pub struct GamutMatrix(/* private fields */);Expand description
A 3×3 row-major matrix between linear-light tristimulus spaces, in f32.
The array stays private so that the representation can change. Kernels read it
through rows.
use zenpixels_convert::{Primaries, gamut::GamutMatrix};
let to_srgb = GamutMatrix::between(Primaries::DisplayP3, Primaries::Bt709).unwrap();
let mut row = [[1.0_f32, 1.0, 1.0], [0.5, 0.5, 0.5]];
to_srgb.apply_row_rgb(&mut row);
assert!((row[1][0] - 0.5).abs() < 1e-4, "gray stays gray");Implementations§
Source§impl GamutMatrix
impl GamutMatrix
Sourcepub const fn to_xyz(primaries: Primaries) -> Option<&'static Self>
pub const fn to_xyz(primaries: Primaries) -> Option<&'static Self>
Linear RGB in primaries → CIE XYZ (D65), or None for unknown primaries.
Sourcepub const fn from_xyz(primaries: Primaries) -> Option<&'static Self>
pub const fn from_xyz(primaries: Primaries) -> Option<&'static Self>
CIE XYZ (D65) → linear RGB in primaries, or None for unknown primaries.
Sourcepub const fn between(from: Primaries, to: Primaries) -> Option<Self>
pub const fn between(from: Primaries, to: Primaries) -> Option<Self>
The matrix taking linear RGB in from to linear RGB in to.
Equal primaries give the identity. None when either is
Unknown.
Sourcepub fn apply_row_rgb(&self, row: &mut [[f32; 3]])
pub fn apply_row_rgb(&self, row: &mut [[f32; 3]])
Apply in place to a row of RGB pixels in linear light.
Sourcepub fn apply_row_rgba(&self, row: &mut [[f32; 4]])
pub fn apply_row_rgba(&self, row: &mut [[f32; 4]])
Apply in place to a row of RGBA pixels in linear light. Alpha is unchanged.
Trait Implementations§
Source§impl Clone for GamutMatrix
impl Clone for GamutMatrix
Source§fn clone(&self) -> GamutMatrix
fn clone(&self) -> GamutMatrix
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for GamutMatrix
Source§impl Debug for GamutMatrix
impl Debug for GamutMatrix
Source§impl PartialEq for GamutMatrix
impl PartialEq for GamutMatrix
impl StructuralPartialEq for GamutMatrix
Auto Trait Implementations§
impl Freeze for GamutMatrix
impl RefUnwindSafe for GamutMatrix
impl Send for GamutMatrix
impl Sync for GamutMatrix
impl Unpin for GamutMatrix
impl UnsafeUnpin for GamutMatrix
impl UnwindSafe for GamutMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more