Skip to content
Snippets Groups Projects
Commit 0f051b62 authored by Kornel's avatar Kornel
Browse files

Conversions

parent ad68ff4f
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,9 @@ pub trait CIEXYZExt: Sized {
/// Colorimetric space conversion.
fn to_lab(&self, white_point: &CIEXYZ) -> CIELab;
/// Decodes a XYZ value, encoded on ICC convention
fn from_encoded(icc: &[u16; 3]) -> Self;
}
impl CIEXYZExt for CIEXYZ {
......@@ -54,6 +57,14 @@ impl CIEXYZExt for CIEXYZ {
}
out
}
fn from_encoded(icc: &[u16; 3]) -> Self {
let mut out = Self::default();
unsafe {
ffi::cmsXYZEncoded2Float(&mut out, icc.as_ptr());
}
out
}
}
/// White point
......@@ -121,6 +132,12 @@ pub trait CIELabExt: Sized {
/// Encodes a Lab value, from a CIELab value to ICC v2 convention.
fn encoded_v2(&self) -> [u16; 3];
/// Decodes a Lab value, encoded on ICC v4 convention
fn from_encoded(icc: &[u16; 3]) -> Self;
/// Decodes a Lab value, encoded on ICC v2 convention
fn from_encoded_v2(icc: &[u16; 3]) -> Self;
/// Colorimetric space conversion.
fn to_xyz(&self, white_point: &CIEXYZ) -> CIEXYZ;
}
......@@ -178,6 +195,22 @@ impl CIELabExt for CIELab {
out
}
fn from_encoded(icc: &[u16; 3]) -> Self {
let mut out = Self::default();
unsafe {
ffi::cmsLabEncoded2Float(&mut out, icc.as_ptr());
}
out
}
fn from_encoded_v2(icc: &[u16; 3]) -> Self {
let mut out = Self::default();
unsafe {
ffi::cmsLabEncoded2FloatV2(&mut out, icc.as_ptr());
}
out
}
fn to_xyz(&self, white_point: &CIEXYZ) -> CIEXYZ {
let mut out = CIEXYZ::default();
unsafe {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment