1 // Created on: 2012-07-18
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Image_Color_H__
17 #define _Image_Color_H__
19 #include <Standard.hxx>
21 //! POD structure for packed RGB color value (3 bytes)
26 typedef Standard_Byte ComponentType_t;
28 //! Returns the number of components.
29 static Standard_Integer Length()
34 public: // access methods
36 //! Alias to 1st component (red intensity).
37 Standard_Byte r() const { return v[0]; }
39 //! Alias to 2nd component (green intensity).
40 Standard_Byte g() const { return v[1]; }
42 //! Alias to 3rd component (blue intensity).
43 Standard_Byte b() const { return v[2]; }
45 //! Alias to 1st component (red intensity).
46 Standard_Byte& r() { return v[0]; }
48 //! Alias to 2nd component (green intensity).
49 Standard_Byte& g() { return v[1]; }
51 //! Alias to 3rd component (blue intensity).
52 Standard_Byte& b() { return v[2]; }
60 //! POD structure for packed RGB color value (4 bytes with extra byte for alignment)
61 struct Image_ColorRGB32
65 typedef Standard_Byte ComponentType_t;
67 //! Returns the number of components.
68 static Standard_Integer Length()
73 //! Alias to 1st component (red intensity).
74 Standard_Byte r() const { return v[0]; }
76 //! Alias to 2nd component (green intensity).
77 Standard_Byte g() const { return v[1]; }
79 //! Alias to 3rd component (blue intensity).
80 Standard_Byte b() const { return v[2]; }
82 //! Alias to 4th component (dummy).
83 Standard_Byte a_() const { return v[3]; }
85 //! Alias to 1st component (red intensity).
86 Standard_Byte& r() { return v[0]; }
88 //! Alias to 2nd component (green intensity).
89 Standard_Byte& g() { return v[1]; }
91 //! Alias to 3rd component (blue intensity).
92 Standard_Byte& b() { return v[2]; }
94 //! Alias to 4th component (dummy).
95 Standard_Byte& a_() { return v[3]; }
103 //! POD structure for packed RGBA color value (4 bytes)
104 struct Image_ColorRGBA
108 typedef Standard_Byte ComponentType_t;
110 //! Returns the number of components.
111 static Standard_Integer Length()
116 //! Alias to 1st component (red intensity).
117 Standard_Byte r() const { return v[0]; }
119 //! Alias to 2nd component (green intensity).
120 Standard_Byte g() const { return v[1]; }
122 //! Alias to 3rd component (blue intensity).
123 Standard_Byte b() const { return v[2]; }
125 //! Alias to 4th component (alpha value).
126 Standard_Byte a() const { return v[3]; }
128 //! Alias to 1st component (red intensity).
129 Standard_Byte& r() { return v[0]; }
131 //! Alias to 2nd component (green intensity).
132 Standard_Byte& g() { return v[1]; }
134 //! Alias to 3rd component (blue intensity).
135 Standard_Byte& b() { return v[2]; }
137 //! Alias to 4th component (alpha value).
138 Standard_Byte& a() { return v[3]; }
146 //! POD structure for packed BGR color value (3 bytes)
147 struct Image_ColorBGR
151 typedef Standard_Byte ComponentType_t;
153 //! Returns the number of components.
154 static Standard_Integer Length()
159 //! Alias to 3rd component (red intensity).
160 Standard_Byte r() const { return v[2]; }
162 //! Alias to 2nd component (green intensity).
163 Standard_Byte g() const { return v[1]; }
165 //! Alias to 1st component (blue intensity).
166 Standard_Byte b() const { return v[0]; }
168 //! Alias to 3rd component (red intensity).
169 Standard_Byte& r() { return v[2]; }
171 //! Alias to 2nd component (green intensity).
172 Standard_Byte& g() { return v[1]; }
174 //! Alias to 1st component (blue intensity).
175 Standard_Byte& b() { return v[0]; }
183 //! POD structure for packed BGR color value (4 bytes with extra byte for alignment)
184 struct Image_ColorBGR32
188 typedef Standard_Byte ComponentType_t;
190 //! Returns the number of components.
191 static Standard_Integer Length()
196 //! Alias to 3rd component (red intensity).
197 Standard_Byte r() const { return v[2]; }
199 //! Alias to 2nd component (green intensity).
200 Standard_Byte g() const { return v[1]; }
202 //! Alias to 1st component (blue intensity).
203 Standard_Byte b() const { return v[0]; }
205 //! Alias to 4th component (dummy).
206 Standard_Byte a_() const { return v[3]; }
208 //! Alias to 3rd component (red intensity).
209 Standard_Byte& r() { return v[2]; }
211 //! Alias to 2nd component (green intensity).
212 Standard_Byte& g() { return v[1]; }
214 //! Alias to 1st component (blue intensity).
215 Standard_Byte& b() { return v[0]; }
217 //! Alias to 4th component (dummy).
218 Standard_Byte& a_() { return v[3]; }
226 //! POD structure for packed BGRA color value (4 bytes)
227 struct Image_ColorBGRA
231 typedef Standard_Byte ComponentType_t;
233 //! Returns the number of components.
234 static Standard_Integer Length()
239 //! Alias to 3rd component (red intensity).
240 Standard_Byte r() const { return v[2]; }
242 //! Alias to 2nd component (green intensity).
243 Standard_Byte g() const { return v[1]; }
245 //! Alias to 1st component (blue intensity).
246 Standard_Byte b() const { return v[0]; }
248 //! Alias to 4th component (alpha value).
249 Standard_Byte a() const { return v[3]; }
251 //! Alias to 3rd component (red intensity).
252 Standard_Byte& r() { return v[2]; }
254 //! Alias to 2nd component (green intensity).
255 Standard_Byte& g() { return v[1]; }
257 //! Alias to 1st component (blue intensity).
258 Standard_Byte& b() { return v[0]; }
260 //! Alias to 4th component (alpha value).
261 Standard_Byte& a() { return v[3]; }
269 //! POD structure for packed float RG color value (2 floats)
270 struct Image_ColorRGF
273 typedef Standard_ShortReal ComponentType_t;
275 //! Returns the number of components.
276 static Standard_Integer Length() { return 2; }
278 //! Alias to 1st component (red intensity).
279 Standard_ShortReal r() const { return v[0]; }
281 //! Alias to 2nd component (green intensity).
282 Standard_ShortReal g() const { return v[1]; }
284 //! Alias to 1st component (red intensity).
285 Standard_ShortReal& r() { return v[0]; }
287 //! Alias to 2nd component (green intensity).
288 Standard_ShortReal& g() { return v[1]; }
291 Standard_ShortReal v[2];
294 //! POD structure for packed float RGB color value (3 floats)
295 struct Image_ColorRGBF
299 typedef Standard_ShortReal ComponentType_t;
301 //! Returns the number of components.
302 static Standard_Integer Length()
307 //! Alias to 1st component (red intensity).
308 Standard_ShortReal r() const { return v[0]; }
310 //! Alias to 2nd component (green intensity).
311 Standard_ShortReal g() const { return v[1]; }
313 //! Alias to 3rd component (blue intensity).
314 Standard_ShortReal b() const { return v[2]; }
316 //! Alias to 1st component (red intensity).
317 Standard_ShortReal& r() { return v[0]; }
319 //! Alias to 2nd component (green intensity).
320 Standard_ShortReal& g() { return v[1]; }
322 //! Alias to 3rd component (blue intensity).
323 Standard_ShortReal& b() { return v[2]; }
327 Standard_ShortReal v[3];
331 //! POD structure for packed BGR float color value (3 floats)
332 struct Image_ColorBGRF
336 typedef Standard_ShortReal ComponentType_t;
338 //! Returns the number of components.
339 static Standard_Integer Length()
344 //! Alias to 3rd component (red intensity).
345 Standard_ShortReal r() const { return v[2]; }
347 //! Alias to 2nd component (green intensity).
348 Standard_ShortReal g() const { return v[1]; }
350 //! Alias to 1st component (blue intensity).
351 Standard_ShortReal b() const { return v[0]; }
353 //! Alias to 3rd component (red intensity).
354 Standard_ShortReal& r() { return v[2]; }
356 //! Alias to 2nd component (green intensity).
357 Standard_ShortReal& g() { return v[1]; }
359 //! Alias to 1st component (blue intensity).
360 Standard_ShortReal& b() { return v[0]; }
364 Standard_ShortReal v[3];
368 //! POD structure for packed RGBA color value (4 floats)
369 struct Image_ColorRGBAF
373 typedef Standard_ShortReal ComponentType_t;
375 //! Returns the number of components.
376 static Standard_Integer Length()
381 //! Alias to 1st component (red intensity).
382 Standard_ShortReal r() const { return v[0]; }
384 //! Alias to 2nd component (green intensity).
385 Standard_ShortReal g() const { return v[1]; }
387 //! Alias to 3rd component (blue intensity).
388 Standard_ShortReal b() const { return v[2]; }
390 //! Alias to 4th component (alpha value).
391 Standard_ShortReal a() const { return v[3]; }
393 //! Alias to 1st component (red intensity).
394 Standard_ShortReal& r() { return v[0]; }
396 //! Alias to 2nd component (green intensity).
397 Standard_ShortReal& g() { return v[1]; }
399 //! Alias to 3rd component (blue intensity).
400 Standard_ShortReal& b() { return v[2]; }
402 //! Alias to 4th component (alpha value).
403 Standard_ShortReal& a() { return v[3]; }
407 Standard_ShortReal v[4];
411 //! POD structure for packed float BGRA color value (4 floats)
412 struct Image_ColorBGRAF
416 typedef Standard_ShortReal ComponentType_t;
418 //! Returns the number of components.
419 static Standard_Integer Length()
424 //! Alias to 3rd component (red intensity).
425 Standard_ShortReal r() const { return v[2]; }
427 //! Alias to 2nd component (green intensity).
428 Standard_ShortReal g() const { return v[1]; }
430 //! Alias to 1st component (blue intensity).
431 Standard_ShortReal b() const { return v[0]; }
433 //! Alias to 4th component (alpha value).
434 Standard_ShortReal a() const { return v[3]; }
436 //! Alias to 3rd component (red intensity).
437 Standard_ShortReal& r() { return v[2]; }
439 //! Alias to 2nd component (green intensity).
440 Standard_ShortReal& g() { return v[1]; }
442 //! Alias to 1st component (blue intensity).
443 Standard_ShortReal& b() { return v[0]; }
445 //! Alias to 4th component (alpha value).
446 Standard_ShortReal& a() { return v[3]; }
450 Standard_ShortReal v[4];
454 #endif // _Image_Color_H__