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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
use Path;
/// Represents different color space models used in digital imaging and printing.
///
/// A color space defines how colors are represented and interpreted in a digital
/// context. Each variant corresponds to a specific color model with distinct
/// characteristics and use cases.
///
/// # Variants
///
/// * `Srgb` - Standard RGB color space, the most common color space for web
/// and digital displays. Uses gamma correction and is device-independent.
///
/// * `Cmyk` - Cyan, Magenta, Yellow, and Key (Black) color model used primarily
/// in color printing. Subtractive color mixing system where colors are created
/// by subtracting light from white.
///
/// * `Gray` - Grayscale color space representing images using only shades of gray,
/// from black (0%) to white (100%). Each pixel contains only intensity information.
///
/// * `Rgb` - Generic RGB color space representing colors as combinations of Red,
/// Green, and Blue light. Additive color mixing system where colors are created
/// by adding light to black.
///
/// # Examples
///
/// ```no_test
/// use my_crate::ColorSpace;
///
/// let color_space = ColorSpace::Srgb;
/// assert_eq!(color_space, ColorSpace::Srgb);
///
/// match color_space {
/// ColorSpace::Srgb => println!("Standard RGB color space"),
/// ColorSpace::Cmyk => println!("CMYK color space for printing"),
/// ColorSpace::Gray => println!("Grayscale color space"),
/// ColorSpace::Rgb => println!("Generic RGB color space"),
/// }
/// ```
///
/// # Derives
///
/// This enum automatically derives:
/// * `Debug` - For debugging and display purposes
/// * `Clone` - To create copies of color space values
/// * `Copy` - To enable copy semantics (stack-only data)
/// * `PartialEq` - To compare color spaces for equality
/// * `Eq` - To enable total equality comparison
/// An ICC (International Color Consortium) profile representation.
///
/// This structure encapsulates the raw ICC profile data and its associated color space information.
/// ICC profiles are used to ensure consistent color reproduction across different devices and
/// applications by defining the color characteristics of input, display, and output devices.
///
/// # Fields
/// * `bytes` - The raw ICC profile data as a vector of bytes
/// * `color_space` - The color space associated with this ICC profile
///
/// # Examples
/// ```no_test
/// // Create an ICC profile instance
/// let profile = IccProfile {
/// bytes: vec![/* ICC profile data */],
/// color_space: ColorSpace::Rgb,
/// };
/// ```
/// Detects the color space from raw byte data by examining specific header bytes.
///
/// This function inspects the byte slice to determine the color space format.
/// It checks bytes 16-19 (4 bytes) for specific color space signatures.
///
/// # Arguments
///
/// * `bytes` - A slice of bytes containing image or color data
///
/// # Returns
///
/// * `ColorSpace` - The detected color space variant:
/// - `ColorSpace::Cmyk` if bytes 16-19 contain "CMYK"
/// - `ColorSpace::Gray` if bytes 16-19 contain "GRAY"
/// - `ColorSpace::Rgb` if bytes 16-19 contain "RGB" or if:
/// - The byte slice is less than 20 bytes long
/// - The signature doesn't match any known color space
///
/// # Examples
///
/// ```no_test
/// // Assuming ColorSpace enum is defined
/// let rgb_data = [0u8; 32];
/// assert_eq!(detect_color_space(&rgb_data), ColorSpace::Rgb);
///
/// let cmyk_header = b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00CMYK";
/// assert_eq!(detect_color_space(cmyk_header), ColorSpace::Cmyk);
/// ```