Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cColorRef.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cColorRef_H
7 #define _INC_cColorRef_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 #include "GrayCore/include/cMem.h"
15 
17 #ifdef __linux__
18 typedef UINT32 COLORREF;
19 #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((COLORREF)(BYTE)(b))<<16))) // = COLORREF
20 #define CLR_INVALID 0xFFFFFFFF
21 #endif
22 
23 #ifndef D3DCOLOR_DEFINED // ! defined(_d3d9TYPES_H_) defined(USE_DX)
24 typedef DWORD D3DCOLOR;
25 #define D3DCOLOR_DEFINED
26 #endif
27 #ifndef D3DCOLOR_ARGB
28 #define D3DCOLOR_ARGB(a,r,g,b) ((D3DCOLOR)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
29 #define D3DCOLOR_XRGB(r,g,b) D3DCOLOR_ARGB(0xff,r,g,b)
30 #endif
31 
32 namespace GrayLib
33 {
34  typedef BYTE COLOR_ELEM_t;
35  static const COLOR_ELEM_t COLOR_ALPHA_TRANSPARENT = 0;
36  static const COLOR_ELEM_t COLOR_ALPHA_OPAQUE = 0xff;
37  static const COLOR_ELEM_t COLOR_ELEM_MAX = 0xff;
38 
39  typedef WORD COLOR16_t;
40  typedef WORD COLOR565_t;
41  typedef WORD COLOR555_t;
42 
43  class cColorRef
44  {
52 
53  public:
55 
56  public:
57  cColorRef(COLORREF color = 0) noexcept
58  : m_color(color)
59  {
60  }
62  : m_color(GetRGB(r, g, b))
63  {
64  }
65 
66  inline bool isValidColor() const noexcept
67  {
68  // fully transparent white is not considered to be valid. COLOR_ALPHA_TRANSPARENT. ??? this isnt right !
69  return m_color != CLR_INVALID;
70  }
71 
72  inline COLOR_ELEM_t GetElem(ITERATE_t i) const noexcept
73  {
77 #ifdef USE_LITTLE_ENDIAN
78  return ((const COLOR_ELEM_t*)&m_color)[i];
79 #else
80  return ((const COLOR_ELEM_t*)&m_color)[3 - i];
81 #endif
82  }
83  static inline COLORREF GetRGB(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
84  {
86  return (((COLORREF)r) | (((COLORREF)g) << 8) | (((COLORREF)b) << 16));
87  }
88  static inline COLOR_ELEM_t GetR(COLORREF color) noexcept
89  {
91  return ((COLOR_ELEM_t)color);
92  }
93  static inline COLOR_ELEM_t GetG(COLORREF color) noexcept
94  {
96  return ((COLOR_ELEM_t)(color >> 8));
97  }
98  static inline COLOR_ELEM_t GetB(COLORREF color) noexcept
99  {
101  return ((COLOR_ELEM_t)(color >> 16));
102  }
103 
104  static inline D3DCOLOR ToD3D(COLORREF color) noexcept
105  {
106  return GetRGB(GetB(color), GetG(color), GetR(color));
107  }
108  static inline COLORREF FromD3D(D3DCOLOR color) noexcept
109  {
110  return GetRGB(GetB(color), GetG(color), GetR(color));
111  }
112 
113  operator COLORREF () const noexcept
114  {
115  return m_color;
116  }
117  inline COLOR_ELEM_t get_R() const noexcept
118  {
119  return GetR(m_color);
120  }
121  inline COLOR_ELEM_t get_G() const noexcept
122  {
123  return GetG(m_color);
124  }
125  inline COLOR_ELEM_t get_B() const noexcept
126  {
127  return GetB(m_color);
128  }
129 
130  inline COLOR16_t get_Grey16() const noexcept
131  {
132  return ((COLOR16_t)(get_R() | get_G() | get_B())) << 8;
133  }
134 
135  inline COLORREF get_ColorRef() const noexcept
136  {
137  return m_color;
138  }
139  inline D3DCOLOR get_ColorDX() const noexcept
140  {
141  // Convert from GUI color to DX color.
142  return ToD3D(m_color);
143  }
144  };
145 
146  class cColorDX
147  {
155  public:
157 
158  public:
159  cColorDX(D3DCOLOR color = 0) noexcept
160  : m_color(color)
161  {
162  }
164  : m_color(GetXRGB(r, g, b))
165  {
166  }
168  : m_color(GetARGB(a, r, g, b))
169  {
170  }
171 
172  static const D3DCOLOR k_ALPHA_MASK = 0xFF000000;
173  static const int k_ALPHA_SHIFT = 24;
174 
175  operator D3DCOLOR () const noexcept
176  {
177  return m_color;
178  }
179  static inline COLOR_ELEM_t GetA(D3DCOLOR color) noexcept
180  {
182  return ((COLOR_ELEM_t)(color >> k_ALPHA_SHIFT));
183  }
184  static inline COLOR_ELEM_t GetR(D3DCOLOR color) noexcept
185  {
187  return ((COLOR_ELEM_t)(color >> 16));
188  }
189  static inline COLOR_ELEM_t GetG(D3DCOLOR color) noexcept
190  {
192  return ((COLOR_ELEM_t)(color >> 8));
193  }
194  static inline COLOR_ELEM_t GetB(D3DCOLOR color) noexcept
195  {
197  return ((COLOR_ELEM_t)color);
198  }
199 
200  static inline D3DCOLOR GetAC(COLOR_ELEM_t alpha, D3DCOLOR color) noexcept
201  {
203  return ((color &~k_ALPHA_MASK) | (((D3DCOLOR)alpha) << k_ALPHA_SHIFT));
204  }
206  {
210  return ((((D3DCOLOR)a) << 24) | (((D3DCOLOR)r) << 16) | (((D3DCOLOR)g) << 8) | ((D3DCOLOR)b));
211  }
212  static inline D3DCOLOR GetXRGB(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
213  {
215  return GetARGB(COLOR_ALPHA_OPAQUE, r, g, b);
216  }
217 
219  {
221  ASSERT(IS_INDEX_GOOD(i, 4));
222 #ifdef USE_LITTLE_ENDIAN
223  return ((const COLOR_ELEM_t*)&m_color)[i];
224 #else
225  return ((const COLOR_ELEM_t*)&m_color)[3 - i];
226 #endif
227  }
228 
229  inline COLOR_ELEM_t get_R() const noexcept
230  {
231  return GetR(m_color);
232  }
233  inline COLOR_ELEM_t get_G() const noexcept
234  {
235  return GetG(m_color);
236  }
237  inline COLOR_ELEM_t get_B() const noexcept
238  {
239  return GetB(m_color);
240  }
241  inline COLOR_ELEM_t get_A() const noexcept
242  {
243  return GetA(m_color);
244  }
245 
246  inline void put_A(COLOR_ELEM_t a) noexcept
247  {
249  m_color &= ~k_ALPHA_MASK;
250  m_color |= ((D3DCOLOR)a) << k_ALPHA_SHIFT;
251  }
252  inline void put_RGB(D3DCOLOR c) noexcept
253  {
256  m_color |= (c&~k_ALPHA_MASK);
257  }
258 
259  inline COLOR16_t get_Grey16() const noexcept
260  {
261  return ((COLOR16_t)(get_R() | get_G() | get_B())) << 8;
262  }
263  inline COLORREF get_ColorRef() const noexcept
264  {
265  // Convert from DX color to GUI color.
266  return cColorRef::FromD3D(m_color);
267  }
268  inline D3DCOLOR get_ColorDX() const noexcept
269  {
270  return m_color;
271  }
272  };
273 
274 #pragma pack(1)
276  {
280  public:
284  public:
285  cColor888() noexcept
286  {
287  // uninitialized.
288  }
289  cColor888(COLORREF color) noexcept
290  : r(cColorRef::GetR(color)), g(cColorRef::GetG(color)), b(cColorRef::GetB(color))
291  {
292  }
294  : r(_r), g(_g), b(_b)
295  {
296  }
297  bool operator == (const cColor888& color2) const noexcept
298  {
299  return !::memcmp(this, &color2, sizeof(color2)) ;
300  }
301  bool operator != (const cColor888& color2) const noexcept
302  {
303  return ::memcmp(this, &color2, sizeof(color2)) ;
304  }
305 
306  inline COLOR_ELEM_t GetElem(ITERATE_t i) const noexcept
307  {
309  DEBUG_CHECK(IS_INDEX_GOOD(i, 3));
310  return (&r)[i];
311  }
312 
313  inline COLOR_ELEM_t get_R() const noexcept
314  {
315  return r;
316  }
317  inline COLOR_ELEM_t get_G() const noexcept
318  {
319  return g;
320  }
321  inline COLOR_ELEM_t get_B() const noexcept
322  {
323  return b;
324  }
325 
326  inline COLORREF get_ColorRef() const noexcept
327  {
329  return cColorRef::GetRGB(r, g, b);
330  }
331  inline D3DCOLOR get_ColorDX() const noexcept
332  {
334  return cColorDX::GetXRGB(r, g, b);
335  }
336  };
337 
338  class cColor555
339  {
342  public:
343  static const COLOR555_t k_ALPHA_MASK = 0x8000;
345 
346  public:
347  static COLOR555_t inline Make(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b, bool bOpaque) noexcept
348  {
349  const COLOR555_t wAlpha = bOpaque ? k_ALPHA_MASK : 0;
350  return (b >> 3) | (((COLOR555_t)g & 0xf8) << 2) | (((COLOR555_t)r & 0xf8) << 7) | wAlpha;
351  }
352  cColor555(COLOR555_t c = 0) noexcept
353  : m_color(c)
354  {
355  }
356  cColor555(COLOR_ELEM_t _r, COLOR_ELEM_t _g, COLOR_ELEM_t _b, bool bOpaque = true) noexcept
357  : m_color(Make(_r, _g, _b, bOpaque))
358  {
359  }
360 
361  operator COLOR555_t () const noexcept
362  {
363  return m_color;
364  }
365 
366  inline COLOR_ELEM_t get_R() const noexcept
367  {
368  // convert 5 bits to 8 bits.
369  return (COLOR_ELEM_t)((m_color & 0x7c00) >> (10 - 3));
370  }
371  inline COLOR_ELEM_t get_G() const noexcept
372  {
373  // convert 5 bits to 8 bits.
374  return (COLOR_ELEM_t)((m_color & 0x3e0) >> (5 - 3));
375  }
376  inline COLOR_ELEM_t get_B() const noexcept
377  {
378  // convert 5 bits to 8 bits.
379  return (COLOR_ELEM_t)((m_color & 0x1f) << 3);
380  }
381  inline COLOR_ELEM_t get_A() const noexcept
382  {
383  return (m_color & k_ALPHA_MASK) ? COLOR_ALPHA_OPAQUE : COLOR_ALPHA_TRANSPARENT;
384  }
385 
386  void put_ColorRef(COLORREF cVal) noexcept
387  {
388  m_color = (COLOR555_t)((((cVal >> 3) & 0x1f) << 10) | (((cVal >> (8 + 3)) & 0x1f) << 5) | ((cVal >> (16 + 3)) & 0x1f));
389  }
390  inline COLORREF get_ColorRef() const noexcept
391  {
393  return cColorRef::GetRGB(get_R(), get_G(), get_B());
394  }
395  inline D3DCOLOR get_ColorDX() const noexcept
396  {
398  return cColorDX::GetARGB(get_A(), get_R(), get_G(), get_B());
399  }
400  };
401 
402  class cColor565
403  {
406  public:
408 
409  public:
410  static COLOR565_t inline Make(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
411  {
412  return (b >> 3) | (((COLOR565_t)g & 0xfc) << 3) | (((COLOR565_t)r & 0xf8) << 8);
413  }
414 
415  cColor565(COLOR565_t c = 0) noexcept
416  : m_color(c)
417  {
418  }
420  : m_color(Make(_r, _g, _b))
421  {
422  }
423 
424  operator COLOR565_t () const noexcept
425  {
426  return m_color;
427  }
428  inline COLOR_ELEM_t get_R() const noexcept
429  {
430  return (COLOR_ELEM_t)((m_color & 0xf800) >> (11 - 3));
431  }
432  inline COLOR_ELEM_t get_G() const noexcept
433  {
434  return (COLOR_ELEM_t)((m_color & 0x7e0) >> (5 - 2));
435  }
436  inline COLOR_ELEM_t get_B() const noexcept
437  {
438  return (COLOR_ELEM_t)((m_color & 0x1f) << 3);
439  }
440 
441  void put_ColorRef(COLORREF cVal) noexcept
442  {
443  m_color = (COLOR565_t)((((cVal >> 3) & 0x1f) << 11) | (((cVal >> (8 + 2)) & 0x3f) << 5) | ((cVal >> (16 + 3)) & 0x1f));
444  }
445  inline COLORREF get_ColorRef() const noexcept
446  {
448  return cColorRef::GetRGB(get_R(), get_G(), get_B());
449  }
450  inline D3DCOLOR get_ColorDX() const noexcept
451  {
453  return cColorDX::GetXRGB(get_R(), get_G(), get_B());
454  }
455  };
456 
457 #pragma pack()
458 
460  {
465 #define ColorRefDEF(n,r,g,b) COLORREF_##n = RGB(r,g,b), // RGB cColorRef::GetRGB
466 #include "cColorRefs.tbl"
467 #undef ColorRefDEF
468  };
469 
471  {
476 
477 #define ColorRefDEF(n,r,g,b) D3DCOLOR_##n = D3DCOLOR_XRGB(r,g,b), // D3DCOLOR_XRGB cColorDX::GetXRGB
478 #include "cColorRefs.tbl"
479 #undef ColorRefDEF
480  };
481 
483  {
486 
487  public:
491 
492  public:
493  cColorConv() noexcept
494  : m_cAlphaRef(0)
495  , m_cAlpha555(0)
496  , m_cAlpha565(0)
497  {
498  }
499 
500  static void inline Conv_XRGB8888_RGB888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
501  {
502  // copy 3 bytes
503  pbDst[0] = pbSrc[0];
504  pbDst[1] = pbSrc[1];
505  pbDst[2] = pbSrc[2];
506  }
507  static void inline Conv_BGR888_RGB888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
508  {
509  // reverse 3 bytes
510  // same as Conv_RGB888_BGR888
511  pbDst[0] = pbSrc[2]; // b
512  pbDst[1] = pbSrc[1]; // g
513  pbDst[2] = pbSrc[0]; // r
514  }
515 
516  static void inline Conv_ABGR8888_ARGB8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
517  {
518  // same as Conv_ARGB8888_ABGR8888, Conv_XRGB8888_XBGR8888
519  Conv_BGR888_RGB888(pbSrc, pbDst);
520  pbDst[3] = pbSrc[3]; // a
521  }
522 
523  static void inline Conv_BGR888_XBGR8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
524  {
525  // same as Conv_RGB888_XRGB8888,
526  Conv_XRGB8888_RGB888(pbSrc, pbDst);
527  pbDst[3] = COLOR_ALPHA_OPAQUE; // a
528  }
529  static void inline Conv_BGR888_XRGB8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
530  {
531  // same as Conv_RGB888_XBGR8888
532  Conv_BGR888_RGB888(pbSrc, pbDst);
533  pbDst[3] = COLOR_ALPHA_OPAQUE; // a
534  }
535 
536  void inline Conv_RGB888_ARGB8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
537  {
538  Conv_XRGB8888_RGB888(pbSrc, pbDst);
539  const bool isKey = (pbSrc[0] == m_cAlphaRef.b) && (pbSrc[1] == m_cAlphaRef.g) && (pbSrc[2] == m_cAlphaRef.r);
540  pbDst[3] = isKey ? COLOR_ALPHA_TRANSPARENT : COLOR_ALPHA_OPAQUE;
541  }
542  void inline Conv_BGR888_ABGR8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
543  {
544  Conv_XRGB8888_RGB888(pbSrc, pbDst);
545  const bool isKey = (pbSrc[0] == m_cAlphaRef.r) && (pbSrc[1] == m_cAlphaRef.g) && (pbSrc[2] == m_cAlphaRef.b);
546  pbDst[3] = isKey ? COLOR_ALPHA_TRANSPARENT : COLOR_ALPHA_OPAQUE;
547  }
548 
549  void inline Conv_BGR888_ARGB8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
550  {
551  Conv_BGR888_RGB888(pbSrc, pbDst);
552  const bool isKey = (pbSrc[0] == m_cAlphaRef.r) && (pbSrc[1] == m_cAlphaRef.g) && (pbSrc[2] == m_cAlphaRef.b);
553  pbDst[3] = isKey ? COLOR_ALPHA_TRANSPARENT : COLOR_ALPHA_OPAQUE;
554  }
555  void inline Conv_RGB888_ABGR8888(const COLOR_ELEM_t* pbSrc, COLOR_ELEM_t* pbDst) noexcept
556  {
557  // same as Conv_XRGB8888_ABGR8888
558  Conv_BGR888_RGB888(pbSrc, pbDst);
559  const bool isKey = (pbSrc[0] == m_cAlphaRef.b) && (pbSrc[1] == m_cAlphaRef.g) && (pbSrc[2] == m_cAlphaRef.r);
560  pbDst[3] = isKey ? COLOR_ALPHA_TRANSPARENT : COLOR_ALPHA_OPAQUE;
561  }
562 
563  static COLOR565_t inline Conv_BGR888_RGB565(const COLOR_ELEM_t* pbSrc) noexcept
564  {
565  return (((COLOR565_t)pbSrc[2]) >> 3) | // b
566  (((COLOR565_t)pbSrc[1] & 0xfc) << 3) | // g
567  (((COLOR565_t)pbSrc[0] & 0xf8) << 8); // r
568  }
569  static COLOR565_t inline Conv_RGB888_RGB565(const COLOR_ELEM_t* pbSrc) noexcept
570  {
571  return (((COLOR565_t)pbSrc[0]) >> 3) | // r
572  (((COLOR565_t)pbSrc[1] & 0xfc) << 3) | // g
573  (((COLOR565_t)pbSrc[2] & 0xf8) << 8); // b
574  }
575 
576  static COLOR555_t inline Conv_BGR888_RGB1555(const COLOR_ELEM_t* pbSrc, bool bOpaque) noexcept
577  {
578  COLOR555_t wAlpha = bOpaque ? 0x8000 : 0;
579  return (((COLOR555_t)pbSrc[2]) >> 3) |
580  (((COLOR555_t)pbSrc[1] & 0xf8) << 2) |
581  (((COLOR555_t)pbSrc[0] & 0xf8) << 7) |
582  wAlpha;
583  }
584  static COLOR555_t inline Conv_RGB888_RGB1555(const COLOR_ELEM_t* pbSrc, bool bOpaque) noexcept
585  {
586  COLOR555_t wAlpha = bOpaque ? 0x8000 : 0;
587  return (((COLOR555_t)pbSrc[0]) >> 3) |
588  (((COLOR555_t)pbSrc[1] & 0xf8) << 2) |
589  (((COLOR555_t)pbSrc[2] & 0xf8) << 7) |
590  wAlpha;
591  }
592 
593  static void inline Conv_RGB565_BGR888(COLOR565_t c, COLOR_ELEM_t* pbDst) noexcept
594  {
595  pbDst[0] = ((c >> 8) & 0xf8) | ((c >> 13) & 0x07); // r
596  pbDst[1] = ((c >> 3) & 0xfc) | ((c >> 9) & 0x03); // g
597  pbDst[2] = ((c << 3) & 0xf8) | ((c >> 2) & 0x07); // b
598  }
599  static void inline Conv_RGB565_RGB888(COLOR565_t c, COLOR_ELEM_t* pbDst) noexcept
600  {
601  pbDst[0] = ((c << 3) & 0xf8) | ((c >> 2) & 0x07);
602  pbDst[1] = ((c >> 3) & 0xfc) | ((c >> 9) & 0x03);
603  pbDst[2] = ((c >> 8) & 0xf8) | ((c >> 13) & 0x07);
604  }
605 
606  static void inline Conv_RGB1555_BGR888(COLOR565_t c, COLOR_ELEM_t* pbDst) noexcept
607  {
608  pbDst[0] = ((c >> 7) & 0xf8) | ((c >> 12) & 0x07);
609  pbDst[1] = ((c >> 2) & 0xf8) | ((c >> 7) & 0x07);
610  pbDst[2] = ((c << 3) & 0xf8) | ((c >> 2) & 0x07);
611  }
612  static void inline Conv_RGB1555_RGB888(COLOR565_t c, COLOR_ELEM_t* pbDst) noexcept
613  {
614  pbDst[0] = ((c << 3) & 0xf8) | ((c >> 2) & 0x07);
615  pbDst[1] = ((c >> 2) & 0xf8) | ((c >> 7) & 0x07);
616  pbDst[2] = ((c >> 7) & 0xf8) | ((c >> 12) & 0x07);
617  }
618 
619  static COLOR555_t inline Conv_RGB565_RGB1555(COLOR565_t c, bool bOpaque) noexcept
620  {
621  COLOR555_t wAlpha = bOpaque ? 0x8000 : 0;
622  return ((c >> 1) & 0x7fe0) | (c & 0x1f) | wAlpha;
623  }
624  };
625 }
626 
627 #endif // _INC_cColorRef_H
#define CATTR_PACKED
Definition: GrayCore.h:87
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IS_INDEX_GOOD(i, q)
cast the (likely) int to unsigned to check for negatives.
Definition: Index.h:35
Using X files without the sources and the makefile How to use you just create a debug directory e g
Definition: Readme.txt:21
DWORD D3DCOLOR
Stuff normally defined in windows.h or DirectX headers.
Definition: cColorRef.h:24
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define DEBUG_CHECK(exp)
Definition: cDebugAssert.h:90
UINT32 COLORREF
ABGR (high to low bits)
Definition: cVariantData.h:21
Definition: cColorRef.h:339
cColor555(COLOR_ELEM_t _r, COLOR_ELEM_t _g, COLOR_ELEM_t _b, bool bOpaque=true) noexcept
Definition: cColorRef.h:356
COLORREF get_ColorRef() const noexcept
Definition: cColorRef.h:390
COLOR_ELEM_t get_G() const noexcept
Definition: cColorRef.h:371
D3DCOLOR get_ColorDX() const noexcept
Definition: cColorRef.h:395
COLOR_ELEM_t get_B() const noexcept
Definition: cColorRef.h:376
static COLOR555_t Make(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b, bool bOpaque) noexcept
Definition: cColorRef.h:347
cColor555(COLOR555_t c=0) noexcept
Definition: cColorRef.h:352
void put_ColorRef(COLORREF cVal) noexcept
Definition: cColorRef.h:386
static const COLOR555_t k_ALPHA_MASK
Definition: cColorRef.h:343
COLOR_ELEM_t get_A() const noexcept
Definition: cColorRef.h:381
COLOR_ELEM_t get_R() const noexcept
Definition: cColorRef.h:366
COLOR555_t m_color
Definition: cColorRef.h:344
Definition: cColorRef.h:403
static COLOR565_t Make(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:410
void put_ColorRef(COLORREF cVal) noexcept
Definition: cColorRef.h:441
COLOR565_t m_color
Definition: cColorRef.h:407
COLORREF get_ColorRef() const noexcept
Definition: cColorRef.h:445
COLOR_ELEM_t get_R() const noexcept
Definition: cColorRef.h:428
D3DCOLOR get_ColorDX() const noexcept
Definition: cColorRef.h:450
cColor565(COLOR565_t c=0) noexcept
Definition: cColorRef.h:415
cColor565(COLOR_ELEM_t _r, COLOR_ELEM_t _g, COLOR_ELEM_t _b) noexcept
Definition: cColorRef.h:419
COLOR_ELEM_t get_B() const noexcept
Definition: cColorRef.h:436
COLOR_ELEM_t get_G() const noexcept
Definition: cColorRef.h:432
Definition: cColorRef.h:276
cColor888() noexcept
Definition: cColorRef.h:285
COLORREF get_ColorRef() const noexcept
Definition: cColorRef.h:326
cColor888(COLORREF color) noexcept
Definition: cColorRef.h:289
COLOR_ELEM_t get_G() const noexcept
Definition: cColorRef.h:317
cColor888(COLOR_ELEM_t _r, COLOR_ELEM_t _g, COLOR_ELEM_t _b) noexcept
Definition: cColorRef.h:293
COLOR_ELEM_t get_R() const noexcept
Definition: cColorRef.h:313
COLOR_ELEM_t GetElem(ITERATE_t i) const noexcept
Definition: cColorRef.h:306
D3DCOLOR get_ColorDX() const noexcept
Definition: cColorRef.h:331
COLOR_ELEM_t g
memory is GDI order. [0] = red
Definition: cColorRef.h:282
COLOR_ELEM_t b
Definition: cColorRef.h:283
COLOR_ELEM_t get_B() const noexcept
Definition: cColorRef.h:321
COLOR_ELEM_t r
Definition: cColorRef.h:281
Definition: cColorRef.h:483
static void Conv_BGR888_XRGB8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:529
static void Conv_RGB1555_BGR888(COLOR565_t c, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:606
static void Conv_ABGR8888_ARGB8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:516
cColor555 m_cAlpha555
if 16 bit pixel source. alpha if XRGB1555
Definition: cColorRef.h:489
static void Conv_XRGB8888_RGB888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:500
static void Conv_RGB565_BGR888(COLOR565_t c, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:593
static void Conv_BGR888_RGB888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:507
static COLOR555_t Conv_BGR888_RGB1555(const COLOR_ELEM_t *pbSrc, bool bOpaque) noexcept
Definition: cColorRef.h:576
void Conv_BGR888_ARGB8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:549
static void Conv_RGB565_RGB888(COLOR565_t c, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:599
static COLOR555_t Conv_RGB565_RGB1555(COLOR565_t c, bool bOpaque) noexcept
Definition: cColorRef.h:619
static void Conv_BGR888_XBGR8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:523
static COLOR565_t Conv_RGB888_RGB565(const COLOR_ELEM_t *pbSrc) noexcept
Definition: cColorRef.h:569
static COLOR565_t Conv_BGR888_RGB565(const COLOR_ELEM_t *pbSrc) noexcept
Definition: cColorRef.h:563
static void Conv_RGB1555_RGB888(COLOR565_t c, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:612
cColor565 m_cAlpha565
if 16 bit pixel source. alpha if RGB565
Definition: cColorRef.h:490
void Conv_RGB888_ARGB8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:536
void Conv_BGR888_ABGR8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:542
void Conv_RGB888_ABGR8888(const COLOR_ELEM_t *pbSrc, COLOR_ELEM_t *pbDst) noexcept
Definition: cColorRef.h:555
static COLOR555_t Conv_RGB888_RGB1555(const COLOR_ELEM_t *pbSrc, bool bOpaque) noexcept
Definition: cColorRef.h:584
cColorConv() noexcept
Definition: cColorRef.h:493
cColor888 m_cAlphaRef
if >= 24 bit pixel source. use this color as alpha.
Definition: cColorRef.h:488
Definition: cColorRef.h:147
COLOR16_t get_Grey16() const noexcept
Definition: cColorRef.h:259
static COLOR_ELEM_t GetR(D3DCOLOR color) noexcept
Definition: cColorRef.h:184
COLOR_ELEM_t get_A() const noexcept
Definition: cColorRef.h:241
static D3DCOLOR GetXRGB(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:212
cColorDX(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:163
static COLOR_ELEM_t GetA(D3DCOLOR color) noexcept
Definition: cColorRef.h:179
cColorDX(D3DCOLOR color=0) noexcept
Definition: cColorRef.h:159
static const D3DCOLOR k_ALPHA_MASK
Definition: cColorRef.h:172
COLOR_ELEM_t get_G() const noexcept
Definition: cColorRef.h:233
D3DCOLOR get_ColorDX() const noexcept
Definition: cColorRef.h:268
D3DCOLOR m_color
32 bit color. D3DCOLOR = [0]=blue,[1]=green,[2]=red,[3] = maybe alpha or ignored.
Definition: cColorRef.h:156
COLOR_ELEM_t GetElem(ITERATE_t i) const
Definition: cColorRef.h:218
static COLOR_ELEM_t GetB(D3DCOLOR color) noexcept
Definition: cColorRef.h:194
COLOR_ELEM_t get_R() const noexcept
Definition: cColorRef.h:229
static const int k_ALPHA_SHIFT
Definition: cColorRef.h:173
static COLOR_ELEM_t GetG(D3DCOLOR color) noexcept
Definition: cColorRef.h:189
static D3DCOLOR GetAC(COLOR_ELEM_t alpha, D3DCOLOR color) noexcept
Definition: cColorRef.h:200
COLORREF get_ColorRef() const noexcept
Definition: cColorRef.h:263
COLOR_ELEM_t get_B() const noexcept
Definition: cColorRef.h:237
static D3DCOLOR GetARGB(COLOR_ELEM_t a, COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:205
void put_A(COLOR_ELEM_t a) noexcept
Definition: cColorRef.h:246
cColorDX(COLOR_ELEM_t a, COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:167
void put_RGB(D3DCOLOR c) noexcept
Definition: cColorRef.h:252
Definition: cColorRef.h:44
cColorRef(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:61
static COLORREF GetRGB(COLOR_ELEM_t r, COLOR_ELEM_t g, COLOR_ELEM_t b) noexcept
Definition: cColorRef.h:83
COLORREF m_color
32 bit color. GDI format. [0]=red,[1]=green,[2]=blue,[3] = maybe alpha or ignored.
Definition: cColorRef.h:54
COLOR_ELEM_t get_B() const noexcept
Definition: cColorRef.h:125
COLORREF get_ColorRef() const noexcept
Definition: cColorRef.h:135
COLOR16_t get_Grey16() const noexcept
Definition: cColorRef.h:130
COLOR_ELEM_t get_R() const noexcept
Definition: cColorRef.h:117
bool isValidColor() const noexcept
Definition: cColorRef.h:66
static COLOR_ELEM_t GetG(COLORREF color) noexcept
Definition: cColorRef.h:93
static D3DCOLOR ToD3D(COLORREF color) noexcept
Definition: cColorRef.h:104
static COLOR_ELEM_t GetB(COLORREF color) noexcept
Definition: cColorRef.h:98
COLOR_ELEM_t get_G() const noexcept
Definition: cColorRef.h:121
static COLORREF FromD3D(D3DCOLOR color) noexcept
Definition: cColorRef.h:108
COLOR_ELEM_t GetElem(ITERATE_t i) const noexcept
Definition: cColorRef.h:72
D3DCOLOR get_ColorDX() const noexcept
Definition: cColorRef.h:139
static COLOR_ELEM_t GetR(COLORREF color) noexcept
Definition: cColorRef.h:88
cColorRef(COLORREF color=0) noexcept
Definition: cColorRef.h:57
Definition: cMesh.h:22
WORD COLOR16_t
A 16 bit greyscale color.
Definition: cColorRef.h:39
WORD COLOR555_t
A 16 bit X555 type color pixel. R=high bits, B=low value bits. 1 alpha bit.
Definition: cColorRef.h:41
D3DCOLOR_TYPE_
Definition: cColorRef.h:471
BYTE COLOR_ELEM_t
A single 8 bit color element. alpha, red, green, or blue intensity as 0-255.
Definition: cColorRef.h:34
COLORREF_TYPE_
Definition: cColorRef.h:460
WORD COLOR565_t
A 16 bit 565 type color pixel. R=high bits, B=low value bits.
Definition: cColorRef.h:40
int ITERATE_t
like size_t but signed
Definition: Index.h:28
bool operator!=(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:254
bool operator==(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:250