rcms/lib.rs
1//! Color management library.
2//!
3//! Heavily based on Little CMS.
4//!
5//! # Examples
6//! ## Converting a Color from sRGB to Display P3
7//! See [`link`](link/fn.link.html) for details on linking color profiles.
8//!
9//! ```
10//! # use rcms::{*, color::*, link::link, profile::Intent};
11//! let srgb_profile = IccProfile::new_srgb();
12//! let p3_profile = IccProfile::new_display_p3();
13//!
14//! // a light-bluish color in sRGB
15//! // colors are represented as arrays of floating-point numbers, usually in the range
16//! // from 0 to 1.
17//! let some_color = [0.3, 0.5, 0.9];
18//!
19//! // create a transform from sRGB to Display P3
20//! let transform_pipeline = link(
21//! &[&srgb_profile, &p3_profile],
22//! &[Intent::Perceptual, Intent::Perceptual],
23//! &[false, false],
24//! &[0., 0.],
25//! ).expect("failed to create color transform");
26//!
27//! // this array will hold the output color in Display P3
28//! let mut out_color = [0.; 3];
29//! transform_pipeline.transform(&some_color, &mut out_color);
30//!
31//! // reference values from ColorSync
32//! let out_reference: [f64; 3] = [0.3462, 0.4949, 0.8724];
33//!
34//! // check that apart from floating point inaccuracies, the output color is correct
35//! assert!((out_color[0] - out_reference[0]).abs() < 1e-3);
36//! assert!((out_color[1] - out_reference[1]).abs() < 1e-3);
37//! assert!((out_color[2] - out_reference[2]).abs() < 1e-3);
38//! ```
39
40#[macro_use]
41mod util;
42
43mod black_point;
44pub mod color;
45pub mod fixed;
46pub mod link;
47pub mod pipeline;
48pub mod profile;
49pub mod tone_curve;
50
51pub use profile::IccProfile;
52pub use tone_curve::ToneCurve;