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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! Embedded CC0-licensed ICC profiles for common wide-gamut color spaces.
//!
//! All profiles are from [Compact-ICC-Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles)
//! by Clinton Ingram, released under the [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/)
//! public domain dedication. They are embedded at compile time via `include_bytes!()`.
//!
//! # Available profiles
//!
//! | Constant | Color space | Format | Size |
//! |----------|-------------|--------|------|
//! | [`DISPLAY_P3_V4`] | Display P3 | ICC v4 | 480 bytes |
//! | [`DISPLAY_P3_V2`] | Display P3 | ICC v2 | 736 bytes |
//! | [`ADOBE_RGB_V4`] | Adobe RGB (1998) | ICC v4 | 480 bytes |
//! | [`REC2020_V4`] | Rec. 2020 | ICC v4 | 480 bytes |
//! | [`PROPHOTO_V4`] | ProPhoto RGB | ICC v4 | 480 bytes |
//!
//! # Lookup by primaries
//!
//! Use [`icc_profile_for_primaries`] to get the recommended ICC profile bytes
//! for a [`ColorPrimaries`] value. Returns `None` for `Bt709` (sRGB is assumed
//! by default and rarely needs an explicit ICC profile) and `Unknown`.
//!
//! # Precision warnings
//!
//! Rec. 2020 and ProPhoto RGB have very wide gamuts. Using 8-bit precision
//! with these spaces will cause visible banding in gradients. Use 16-bit
//! or f32 precision when working with these profiles.
use crateColorPrimaries;
// ---------------------------------------------------------------------------
// Embedded ICC profiles (CC0 license from Compact-ICC-Profiles)
// https://github.com/saucecontrol/Compact-ICC-Profiles
// ---------------------------------------------------------------------------
/// Display P3 Compatible ICC profile, v4 format (480 bytes).
///
/// Recommended for modern software. ICC v4 profiles are more compact
/// and have better-defined semantics than v2.
///
/// Source: <https://github.com/saucecontrol/Compact-ICC-Profiles> (CC0)
pub const DISPLAY_P3_V4: & = include_bytes!;
/// Display P3 Compatible ICC profile, v2 format (736 bytes).
///
/// Use this for compatibility with older software that doesn't support ICC v4.
/// The "magic" variant includes workarounds for buggy v2 parsers.
///
/// Source: <https://github.com/saucecontrol/Compact-ICC-Profiles> (CC0)
pub const DISPLAY_P3_V2: & = include_bytes!;
/// Adobe RGB (1998) Compatible ICC profile, v4 format (480 bytes).
///
/// Adobe RGB has a wider gamut than sRGB, particularly in cyan-green.
/// Common in photography workflows and print production.
///
/// Source: <https://github.com/saucecontrol/Compact-ICC-Profiles> (CC0)
pub const ADOBE_RGB_V4: & = include_bytes!;
/// Rec. 2020 Compatible ICC profile, v4 format (480 bytes).
///
/// Rec. 2020 has a very wide gamut (~75% of visible colors).
/// **Use 16-bit or f32 precision** to avoid banding.
///
/// Source: <https://github.com/saucecontrol/Compact-ICC-Profiles> (CC0)
pub const REC2020_V4: & = include_bytes!;
/// ProPhoto RGB ICC profile, v4 format (480 bytes).
///
/// ProPhoto RGB has an extremely wide gamut (~90% of visible colors).
/// Some ProPhoto colors are outside human vision (imaginary colors).
/// **Use 16-bit or f32 precision** to avoid severe banding.
///
/// ProPhoto is used as an editing space in Lightroom and other RAW processors.
/// Convert to a smaller gamut (P3, sRGB) before final output.
///
/// Source: <https://github.com/saucecontrol/Compact-ICC-Profiles> (CC0)
pub const PROPHOTO_V4: & = include_bytes!;
/// Get the recommended ICC profile for a set of color primaries.
///
/// Returns the v4 ICC profile bytes for the given primaries, or `None` if
/// no embedded profile is available. Returns `None` for [`ColorPrimaries::Bt709`]
/// because sRGB is the assumed default and rarely needs an explicit ICC profile.
///
/// # Examples
///
/// ```
/// use zenpixels_convert::icc_profiles::icc_profile_for_primaries;
/// use zenpixels_convert::ColorPrimaries;
///
/// let p3_icc = icc_profile_for_primaries(ColorPrimaries::DisplayP3);
/// assert!(p3_icc.is_some());
/// assert_eq!(p3_icc.unwrap().len(), 480);
///
/// // sRGB returns None (assumed default)
/// assert!(icc_profile_for_primaries(ColorPrimaries::Bt709).is_none());
/// ```
pub const
/// Get the Display P3 ICC profile, choosing v4 or v2 format.
///
/// Returns v4 by default, or v2 if `prefer_v2` is true (for compatibility
/// with older software).
pub const