1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Check out [higher-level wrapper](https://pornel.github.io/rust-lcms2/lcms2/) for usage in Rust.
//!
//! See [LCMS documentation](https://pornel.github.io/rust-lcms2-sys/) for more information about these functions.

pub mod ffi;
pub use ffi::*;
use std::mem;

#[doc(hidden)]
extern crate libc;

impl CIEXYZ {
    pub fn d50() -> &'static CIEXYZ {
        unsafe { cmsD50_XYZ() }
    }
}

impl CIExyY {
    pub fn d50() -> &'static CIExyY {
        unsafe { cmsD50_xyY() }
    }
}

impl From<CIEXYZ> for CIExyY {
    fn from(f: CIEXYZ) -> Self {
        unsafe {
            let mut new = mem::uninitialized();
            cmsXYZ2xyY(&mut new, &f);
            new
        }
    }
}

impl From<CIExyY> for CIEXYZ {
    fn from(f: CIExyY) -> Self {
        unsafe {
            let mut new = mem::uninitialized();
            cmsxyY2XYZ(&mut new, &f);
            new
        }
    }
}

impl From<CIELab> for CIELCh {
    fn from(f: CIELab) -> Self {
        unsafe {
            let mut new = mem::uninitialized();
            cmsLab2LCh(&mut new, &f);
            new
        }
    }
}

impl From<CIELCh> for CIELab {
    fn from(f: CIELCh) -> Self {
        unsafe {
            let mut new = mem::uninitialized();
            cmsLCh2Lab(&mut new, &f);
            new
        }
    }
}

#[test]
fn it_works() {
    unsafe {
        let c = cmsCreateContext(std::ptr::null_mut(), std::ptr::null_mut());
        cmsDeleteContext(c);

        let xyz:CIEXYZ = ::std::default::Default::default();
        let _:CIExyY = xyz.into();
    }
}