mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1693404 - Add Profile::new_XYZD50(). r=aosmond
This will be useful implementing Profile::approx_eq() Differential Revision: https://phabricator.services.mozilla.com/D105518
This commit is contained in:
parent
abf84904a3
commit
8e60a5afe5
@ -884,4 +884,19 @@ mod test {
|
||||
xfm.apply(&mut data);
|
||||
assert_eq!(data, [4, 30, 80]);
|
||||
}
|
||||
#[test]
|
||||
fn D50() {
|
||||
let p1 = crate::Profile::new_sRGB();
|
||||
let p2 = crate::Profile::new_XYZD50();
|
||||
let xfm = crate::Transform::new(
|
||||
&p1,
|
||||
&p2,
|
||||
crate::DataType::RGB8,
|
||||
crate::Intent::default(),
|
||||
)
|
||||
.unwrap();
|
||||
let mut data = [4, 30, 80];
|
||||
xfm.apply(&mut data);
|
||||
assert_eq!(data, [4, 4, 15]);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use crate::transform::{set_rgb_colorants, PrecacheOuput};
|
||||
use crate::{double_to_s15Fixed16Number, transform::{set_rgb_colorants, PrecacheOuput}};
|
||||
use crate::{matrix::Matrix, s15Fixed16Number, s15Fixed16Number_to_float, Intent, Intent::*};
|
||||
|
||||
pub static SUPPORTS_ICCV4: AtomicBool = AtomicBool::new(cfg!(feature = "iccv4-enabled"));
|
||||
@ -932,6 +932,10 @@ fn curve_from_gamma(gamma: f32) -> Box<curveType> {
|
||||
Box::new(curveType::Curve(vec![float_to_u8Fixed8Number(gamma)]))
|
||||
}
|
||||
|
||||
fn identity_curve() -> Box<curveType> {
|
||||
Box::new(curveType::Curve(Vec::new()))
|
||||
}
|
||||
|
||||
/* from lcms: cmsWhitePointFromTemp */
|
||||
/* tempK must be >= 4000. and <= 25000.
|
||||
* Invalid values of tempK will return
|
||||
@ -1031,6 +1035,29 @@ impl Profile {
|
||||
Profile::new_rgb_with_table(D65, Rec709Primaries, &table).unwrap()
|
||||
}
|
||||
|
||||
/// Create a new profile with D50 adopted white and identity transform functions
|
||||
pub fn new_XYZD50() -> Box<Profile> {
|
||||
let mut profile = profile_create();
|
||||
profile.redColorant.X = double_to_s15Fixed16Number(1.);
|
||||
profile.redColorant.Y = double_to_s15Fixed16Number(0.);
|
||||
profile.redColorant.Z = double_to_s15Fixed16Number(0.);
|
||||
profile.greenColorant.X = double_to_s15Fixed16Number(0.);
|
||||
profile.greenColorant.Y = double_to_s15Fixed16Number(1.);
|
||||
profile.greenColorant.Z = double_to_s15Fixed16Number(0.);
|
||||
profile.blueColorant.X = double_to_s15Fixed16Number(0.);
|
||||
profile.blueColorant.Y = double_to_s15Fixed16Number(0.);
|
||||
profile.blueColorant.Z = double_to_s15Fixed16Number(1.);
|
||||
profile.redTRC = Some(identity_curve());
|
||||
profile.blueTRC = Some(identity_curve());
|
||||
profile.greenTRC = Some(identity_curve());
|
||||
|
||||
profile.class_type = DISPLAY_DEVICE_PROFILE;
|
||||
profile.rendering_intent = Perceptual;
|
||||
profile.color_space = RGB_SIGNATURE;
|
||||
profile.pcs = XYZ_TYPE;
|
||||
profile
|
||||
}
|
||||
|
||||
pub fn new_gray_with_gamma(gamma: f32) -> Box<Profile> {
|
||||
let mut profile = profile_create();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user