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
use ;
use ;
/// Specifies the rendering intent for color management operations.
///
/// Rendering intent determines how colors are mapped when converting between
/// different color spaces or devices. Each intent prioritizes different aspects
/// of color reproduction based on the intended use case.
///
/// # Variants
///
/// * `Perceptual` - Maintains the visual relationship between colors as perceived
/// by the human eye. Best for photographic images where maintaining overall
/// color harmony is important.
///
/// * `RelativeColorimetric` - Preserves exact color relationships within the
/// color gamut while compressing out-of-gamut colors to the closest reproducible
/// colors. Good for graphics and images where color accuracy is critical.
///
/// * `Saturation` - Prioritizes vivid, saturated colors over accurate color
/// reproduction. Best for business graphics like charts and presentations.
///
/// * `AbsoluteColorimetric` - Maintains exact color values regardless of the
/// white point of the destination device. Colors outside the destination
/// gamut are clipped to the nearest reproducible colors.
///
/// # Examples
///
/// ```no_test
/// use your_crate::RenderingIntent;
///
/// let intent = RenderingIntent::Perceptual;
/// println!("{:?}", intent);
/// ```
/// A color transformation wrapper that converts pixel data between different color spaces.
///
/// This struct encapsulates an LCMS2 transform for converting colors from one profile
/// to another. It maintains information about the source and destination channel counts
/// to properly handle pixel data during conversion.
///
/// # Type Parameters
/// * `u8` - Input pixel data type (8-bit per channel)
/// * `u8` - Output pixel data type (8-bit per channel)
/// * `lcms2::GlobalContext` - Uses global LCMS context
/// * `lcms2::DisallowCache` - Disables caching for thread safety
///
/// # Fields
/// * `transform` - The underlying LCMS2 transform object that performs the actual color conversion
/// * `src_channels` - Number of channels in the source color space (e.g., 3 for RGB, 4 for CMYK)
/// * `dst_channels` - Number of channels in the destination color space (e.g., 3 for RGB, 4 for CMYK)
///
/// # Example
/// ```no_test
/// // Typical usage would involve creating a transform between two ICC profiles
/// // and then using it to convert pixel data
/// let transform = ColorTransform::new(source_profile, destination_profile);
/// let output_pixels = transform.convert(input_pixels);
/// ```
/// Determines the appropriate pixel format and byte count for a given color space.
///
/// This function maps color spaces to their corresponding pixel formats and returns
/// the number of bytes needed to represent a single pixel in that format.
///
/// # Arguments
///
/// * `cs` - The color space to convert to pixel format
///
/// # Returns
///
/// A tuple containing:
/// * `PixelFormat` - The pixel format enum variant for the given color space
/// * `usize` - The number of bytes per pixel for this format
///
/// # Supported Mappings
///
/// * `ColorSpace::Srgb` | `ColorSpace::Rgb` => `(PixelFormat::RGB_8, 3)` - 24-bit RGB
/// * `ColorSpace::Cmyk` => `(PixelFormat::CMYK_8, 4)` - 32-bit CMYK
/// * `ColorSpace::Gray` => `(PixelFormat::GRAY_8, 1)` - 8-bit grayscale