6aca4d39 |
1 | // Created on: 2012-07-18 |
692613e5 |
2 | // Created by: Kirill GAVRILOV |
6aca4d39 |
3 | // Copyright (c) 2012-2014 OPEN CASCADE SAS |
692613e5 |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
692613e5 |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
692613e5 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
692613e5 |
15 | |
16 | #ifndef _Image_Color_H__ |
17 | #define _Image_Color_H__ |
18 | |
19 | #include <Standard.hxx> |
20 | |
21 | //! POD structure for packed RGB color value (3 bytes) |
22 | struct Image_ColorRGB |
23 | { |
24 | |
9786a9af |
25 | //! Component type. |
26 | typedef Standard_Byte ComponentType_t; |
27 | |
692613e5 |
28 | //! Returns the number of components. |
29 | static Standard_Integer Length() |
30 | { |
31 | return 3; |
32 | } |
33 | |
34 | public: // access methods |
35 | |
36 | //! Alias to 1st component (red intensity). |
37 | Standard_Byte r() const { return v[0]; } |
38 | |
39 | //! Alias to 2nd component (green intensity). |
40 | Standard_Byte g() const { return v[1]; } |
41 | |
42 | //! Alias to 3rd component (blue intensity). |
43 | Standard_Byte b() const { return v[2]; } |
44 | |
45 | //! Alias to 1st component (red intensity). |
46 | Standard_Byte& r() { return v[0]; } |
47 | |
48 | //! Alias to 2nd component (green intensity). |
49 | Standard_Byte& g() { return v[1]; } |
50 | |
51 | //! Alias to 3rd component (blue intensity). |
52 | Standard_Byte& b() { return v[2]; } |
53 | |
54 | public: |
55 | |
56 | Standard_Byte v[3]; |
57 | |
58 | }; |
59 | |
60 | //! POD structure for packed RGB color value (4 bytes with extra byte for alignment) |
61 | struct Image_ColorRGB32 |
62 | { |
63 | |
9786a9af |
64 | //! Component type. |
65 | typedef Standard_Byte ComponentType_t; |
66 | |
692613e5 |
67 | //! Returns the number of components. |
68 | static Standard_Integer Length() |
69 | { |
70 | return 3; |
71 | } |
72 | |
73 | //! Alias to 1st component (red intensity). |
74 | Standard_Byte r() const { return v[0]; } |
75 | |
76 | //! Alias to 2nd component (green intensity). |
77 | Standard_Byte g() const { return v[1]; } |
78 | |
79 | //! Alias to 3rd component (blue intensity). |
80 | Standard_Byte b() const { return v[2]; } |
81 | |
82 | //! Alias to 4th component (dummy). |
83 | Standard_Byte a_() const { return v[3]; } |
84 | |
85 | //! Alias to 1st component (red intensity). |
86 | Standard_Byte& r() { return v[0]; } |
87 | |
88 | //! Alias to 2nd component (green intensity). |
89 | Standard_Byte& g() { return v[1]; } |
90 | |
91 | //! Alias to 3rd component (blue intensity). |
92 | Standard_Byte& b() { return v[2]; } |
93 | |
94 | //! Alias to 4th component (dummy). |
95 | Standard_Byte& a_() { return v[3]; } |
96 | |
97 | public: |
98 | |
99 | Standard_Byte v[4]; |
100 | |
101 | }; |
102 | |
103 | //! POD structure for packed RGBA color value (4 bytes) |
104 | struct Image_ColorRGBA |
105 | { |
106 | |
9786a9af |
107 | //! Component type. |
108 | typedef Standard_Byte ComponentType_t; |
109 | |
692613e5 |
110 | //! Returns the number of components. |
111 | static Standard_Integer Length() |
112 | { |
113 | return 4; |
114 | } |
115 | |
116 | //! Alias to 1st component (red intensity). |
117 | Standard_Byte r() const { return v[0]; } |
118 | |
119 | //! Alias to 2nd component (green intensity). |
120 | Standard_Byte g() const { return v[1]; } |
121 | |
122 | //! Alias to 3rd component (blue intensity). |
123 | Standard_Byte b() const { return v[2]; } |
124 | |
125 | //! Alias to 4th component (alpha value). |
126 | Standard_Byte a() const { return v[3]; } |
127 | |
128 | //! Alias to 1st component (red intensity). |
129 | Standard_Byte& r() { return v[0]; } |
130 | |
131 | //! Alias to 2nd component (green intensity). |
132 | Standard_Byte& g() { return v[1]; } |
133 | |
134 | //! Alias to 3rd component (blue intensity). |
135 | Standard_Byte& b() { return v[2]; } |
136 | |
137 | //! Alias to 4th component (alpha value). |
138 | Standard_Byte& a() { return v[3]; } |
139 | |
140 | public: |
141 | |
142 | Standard_Byte v[4]; |
143 | |
144 | }; |
145 | |
146 | //! POD structure for packed BGR color value (3 bytes) |
147 | struct Image_ColorBGR |
148 | { |
149 | |
9786a9af |
150 | //! Component type. |
151 | typedef Standard_Byte ComponentType_t; |
152 | |
692613e5 |
153 | //! Returns the number of components. |
154 | static Standard_Integer Length() |
155 | { |
156 | return 3; |
157 | } |
158 | |
159 | //! Alias to 3rd component (red intensity). |
160 | Standard_Byte r() const { return v[2]; } |
161 | |
162 | //! Alias to 2nd component (green intensity). |
163 | Standard_Byte g() const { return v[1]; } |
164 | |
165 | //! Alias to 1st component (blue intensity). |
166 | Standard_Byte b() const { return v[0]; } |
167 | |
168 | //! Alias to 3rd component (red intensity). |
169 | Standard_Byte& r() { return v[2]; } |
170 | |
171 | //! Alias to 2nd component (green intensity). |
172 | Standard_Byte& g() { return v[1]; } |
173 | |
174 | //! Alias to 1st component (blue intensity). |
175 | Standard_Byte& b() { return v[0]; } |
176 | |
177 | public: |
178 | |
179 | Standard_Byte v[3]; |
180 | |
181 | }; |
182 | |
183 | //! POD structure for packed BGR color value (4 bytes with extra byte for alignment) |
184 | struct Image_ColorBGR32 |
185 | { |
186 | |
9786a9af |
187 | //! Component type. |
188 | typedef Standard_Byte ComponentType_t; |
189 | |
692613e5 |
190 | //! Returns the number of components. |
191 | static Standard_Integer Length() |
192 | { |
193 | return 3; |
194 | } |
195 | |
196 | //! Alias to 3rd component (red intensity). |
197 | Standard_Byte r() const { return v[2]; } |
198 | |
199 | //! Alias to 2nd component (green intensity). |
200 | Standard_Byte g() const { return v[1]; } |
201 | |
202 | //! Alias to 1st component (blue intensity). |
203 | Standard_Byte b() const { return v[0]; } |
204 | |
205 | //! Alias to 4th component (dummy). |
206 | Standard_Byte a_() const { return v[3]; } |
207 | |
208 | //! Alias to 3rd component (red intensity). |
209 | Standard_Byte& r() { return v[2]; } |
210 | |
211 | //! Alias to 2nd component (green intensity). |
212 | Standard_Byte& g() { return v[1]; } |
213 | |
214 | //! Alias to 1st component (blue intensity). |
215 | Standard_Byte& b() { return v[0]; } |
216 | |
217 | //! Alias to 4th component (dummy). |
218 | Standard_Byte& a_() { return v[3]; } |
219 | |
220 | public: |
221 | |
222 | Standard_Byte v[4]; |
223 | |
224 | }; |
225 | |
226 | //! POD structure for packed BGRA color value (4 bytes) |
227 | struct Image_ColorBGRA |
228 | { |
229 | |
9786a9af |
230 | //! Component type. |
231 | typedef Standard_Byte ComponentType_t; |
232 | |
692613e5 |
233 | //! Returns the number of components. |
234 | static Standard_Integer Length() |
235 | { |
236 | return 4; |
237 | } |
238 | |
239 | //! Alias to 3rd component (red intensity). |
240 | Standard_Byte r() const { return v[2]; } |
241 | |
242 | //! Alias to 2nd component (green intensity). |
243 | Standard_Byte g() const { return v[1]; } |
244 | |
245 | //! Alias to 1st component (blue intensity). |
246 | Standard_Byte b() const { return v[0]; } |
247 | |
248 | //! Alias to 4th component (alpha value). |
249 | Standard_Byte a() const { return v[3]; } |
250 | |
251 | //! Alias to 3rd component (red intensity). |
252 | Standard_Byte& r() { return v[2]; } |
253 | |
254 | //! Alias to 2nd component (green intensity). |
255 | Standard_Byte& g() { return v[1]; } |
256 | |
257 | //! Alias to 1st component (blue intensity). |
258 | Standard_Byte& b() { return v[0]; } |
259 | |
260 | //! Alias to 4th component (alpha value). |
261 | Standard_Byte& a() { return v[3]; } |
262 | |
263 | public: |
264 | |
265 | Standard_Byte v[4]; |
266 | |
267 | }; |
268 | |
269 | //! POD structure for packed float RGB color value (3 floats) |
270 | struct Image_ColorRGBF |
271 | { |
272 | |
9786a9af |
273 | //! Component type. |
274 | typedef Standard_ShortReal ComponentType_t; |
275 | |
692613e5 |
276 | //! Returns the number of components. |
277 | static Standard_Integer Length() |
278 | { |
279 | return 3; |
280 | } |
281 | |
282 | //! Alias to 1st component (red intensity). |
283 | Standard_ShortReal r() const { return v[0]; } |
284 | |
285 | //! Alias to 2nd component (green intensity). |
286 | Standard_ShortReal g() const { return v[1]; } |
287 | |
288 | //! Alias to 3rd component (blue intensity). |
289 | Standard_ShortReal b() const { return v[2]; } |
290 | |
291 | //! Alias to 1st component (red intensity). |
292 | Standard_ShortReal& r() { return v[0]; } |
293 | |
294 | //! Alias to 2nd component (green intensity). |
295 | Standard_ShortReal& g() { return v[1]; } |
296 | |
297 | //! Alias to 3rd component (blue intensity). |
298 | Standard_ShortReal& b() { return v[2]; } |
299 | |
300 | public: |
301 | |
302 | Standard_ShortReal v[3]; |
303 | |
304 | }; |
305 | |
306 | //! POD structure for packed BGR float color value (3 floats) |
307 | struct Image_ColorBGRF |
308 | { |
309 | |
9786a9af |
310 | //! Component type. |
311 | typedef Standard_ShortReal ComponentType_t; |
312 | |
692613e5 |
313 | //! Returns the number of components. |
314 | static Standard_Integer Length() |
315 | { |
316 | return 3; |
317 | } |
318 | |
319 | //! Alias to 3rd component (red intensity). |
320 | Standard_ShortReal r() const { return v[2]; } |
321 | |
322 | //! Alias to 2nd component (green intensity). |
323 | Standard_ShortReal g() const { return v[1]; } |
324 | |
325 | //! Alias to 1st component (blue intensity). |
326 | Standard_ShortReal b() const { return v[0]; } |
327 | |
328 | //! Alias to 3rd component (red intensity). |
329 | Standard_ShortReal& r() { return v[2]; } |
330 | |
331 | //! Alias to 2nd component (green intensity). |
332 | Standard_ShortReal& g() { return v[1]; } |
333 | |
334 | //! Alias to 1st component (blue intensity). |
335 | Standard_ShortReal& b() { return v[0]; } |
336 | |
337 | public: |
338 | |
339 | Standard_ShortReal v[3]; |
340 | |
341 | }; |
342 | |
343 | //! POD structure for packed RGBA color value (4 floats) |
344 | struct Image_ColorRGBAF |
345 | { |
346 | |
9786a9af |
347 | //! Component type. |
348 | typedef Standard_ShortReal ComponentType_t; |
349 | |
692613e5 |
350 | //! Returns the number of components. |
351 | static Standard_Integer Length() |
352 | { |
353 | return 4; |
354 | } |
355 | |
356 | //! Alias to 1st component (red intensity). |
357 | Standard_ShortReal r() const { return v[0]; } |
358 | |
359 | //! Alias to 2nd component (green intensity). |
360 | Standard_ShortReal g() const { return v[1]; } |
361 | |
362 | //! Alias to 3rd component (blue intensity). |
363 | Standard_ShortReal b() const { return v[2]; } |
364 | |
365 | //! Alias to 4th component (alpha value). |
366 | Standard_ShortReal a() const { return v[3]; } |
367 | |
368 | //! Alias to 1st component (red intensity). |
369 | Standard_ShortReal& r() { return v[0]; } |
370 | |
371 | //! Alias to 2nd component (green intensity). |
372 | Standard_ShortReal& g() { return v[1]; } |
373 | |
374 | //! Alias to 3rd component (blue intensity). |
375 | Standard_ShortReal& b() { return v[2]; } |
376 | |
377 | //! Alias to 4th component (alpha value). |
378 | Standard_ShortReal& a() { return v[3]; } |
379 | |
380 | public: |
381 | |
382 | Standard_ShortReal v[4]; |
383 | |
384 | }; |
385 | |
386 | //! POD structure for packed float BGRA color value (4 floats) |
387 | struct Image_ColorBGRAF |
388 | { |
389 | |
9786a9af |
390 | //! Component type. |
391 | typedef Standard_ShortReal ComponentType_t; |
392 | |
692613e5 |
393 | //! Returns the number of components. |
394 | static Standard_Integer Length() |
395 | { |
396 | return 4; |
397 | } |
398 | |
399 | //! Alias to 3rd component (red intensity). |
400 | Standard_ShortReal r() const { return v[2]; } |
401 | |
402 | //! Alias to 2nd component (green intensity). |
403 | Standard_ShortReal g() const { return v[1]; } |
404 | |
405 | //! Alias to 1st component (blue intensity). |
406 | Standard_ShortReal b() const { return v[0]; } |
407 | |
408 | //! Alias to 4th component (alpha value). |
409 | Standard_ShortReal a() const { return v[3]; } |
410 | |
411 | //! Alias to 3rd component (red intensity). |
412 | Standard_ShortReal& r() { return v[2]; } |
413 | |
414 | //! Alias to 2nd component (green intensity). |
415 | Standard_ShortReal& g() { return v[1]; } |
416 | |
417 | //! Alias to 1st component (blue intensity). |
418 | Standard_ShortReal& b() { return v[0]; } |
419 | |
420 | //! Alias to 4th component (alpha value). |
421 | Standard_ShortReal& a() { return v[3]; } |
422 | |
423 | public: |
424 | |
425 | Standard_ShortReal v[4]; |
426 | |
427 | }; |
428 | |
692613e5 |
429 | #endif // _Image_Color_H__ |