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
use super::*;
use std::ptr;
use std::mem;
pub struct CIECAM02 {
handle: ffi::HANDLE,
}
impl CIECAM02 {
pub fn new(conditions: ViewingConditions) -> LCMSResult<Self> {
let handle = unsafe { ffi::cmsCIECAM02Init(ptr::null_mut(), &conditions) };
if !handle.is_null() {
Ok(Self { handle })
} else {
Err(Error::ObjectCreationError)
}
}
pub fn forward(&mut self, input: &CIEXYZ) -> JCh {
unsafe {
let mut out = mem::uninitialized();
ffi::cmsCIECAM02Forward(self.handle, input, &mut out);
out
}
}
pub fn reverse(&mut self, input: &JCh) -> CIEXYZ {
unsafe {
let mut out = mem::uninitialized();
ffi::cmsCIECAM02Reverse(self.handle, input, &mut out);
out
}
}
}
impl Drop for CIECAM02 {
fn drop(&mut self) {
unsafe {
ffi::cmsCIECAM02Done(self.handle);
}
}
}