| 1 |
#ifndef CVD_INCLUDE_BGRX_H |
| 2 |
#define CVD_INCLUDE_BGRX_H |
| 3 |
|
| 4 |
#include <iostream> |
| 5 |
|
| 6 |
namespace CVD |
| 7 |
{ |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
template <typename T> |
| 16 |
class Bgrx |
| 17 |
{ |
| 18 |
public: |
| 19 |
|
| 20 |
explicit Bgrx() |
| 21 |
: blue(0) |
| 22 |
, green(0) |
| 23 |
, red(0) |
| 24 |
, dummy(0) |
| 25 |
{ |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
explicit Bgrx(T b, T g, T r) |
| 33 |
: blue(b) |
| 34 |
, green(g) |
| 35 |
, red(r) |
| 36 |
, dummy(0) |
| 37 |
{ |
| 38 |
} |
| 39 |
|
| 40 |
T blue; |
| 41 |
T green; |
| 42 |
T red; |
| 43 |
T dummy; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
template <typename T2> |
| 48 |
Bgrx<T>& operator=(const Bgrx<T2>& c) |
| 49 |
{ |
| 50 |
blue = static_cast<T>(c.blue); |
| 51 |
green = static_cast<T>(c.green); |
| 52 |
red = static_cast<T>(c.red); |
| 53 |
return *this; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
bool operator==(const Bgrx<T>& c) const |
| 59 |
{ |
| 60 |
return red == c.red && green == c.green && blue == c.blue; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
bool operator!=(const Bgrx<T>& c) const |
| 66 |
{ |
| 67 |
return red != c.red || green != c.green || blue != c.blue; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
template <typename T> |
| 78 |
std::ostream& operator<<(std::ostream& os, const Bgrx<T>& x) |
| 79 |
{ |
| 80 |
return os << "(" << x.blue << "," |
| 81 |
<< x.green << "," << x.red << ")"; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
inline std::ostream& operator<<(std::ostream& os, const Bgrx<unsigned char>& x) |
| 89 |
{ |
| 90 |
return os << "(" |
| 91 |
<< static_cast<unsigned int>(x.blue) << ")" |
| 92 |
<< static_cast<unsigned int>(x.green) << "," |
| 93 |
<< static_cast<unsigned int>(x.red) << ","; |
| 94 |
} |
| 95 |
|
| 96 |
} |
| 97 |
#endif |