14 typedef unsigned char byte;
42 explicit RGB(T v) : Base(v) {}
57 explicit RGB(
const T t[3]): Base(t) {}
64 RGB(
const Base&
x) : Base(x) {}
88 const T&
r()
const {
return (*
this)[0]; }
95 T&
r() {
return (*
this)[0]; }
102 const T&
g()
const {
return (*
this)[1]; }
109 T&
g() {
return (*
this)[1]; }
116 const T&
b()
const {
return (*
this)[2]; }
123 T&
b() {
return (*
this)[2]; }
130 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
137 template <
typename T>
154 explicit RGBA(T
x) : Base(x) { (*this)[3]=T(1); }
162 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=a;
172 (*this)[0]=
r;(*this)[1]=
g;(*this)[2]=
b;(*this)[3]=T(255);
217 const T&
r()
const {
return (*
this)[0]; }
224 T&
r() {
return (*
this)[0]; }
231 const T&
g()
const {
return (*
this)[1]; }
238 T&
g() {
return (*
this)[1]; }
245 const T&
b()
const {
return (*
this)[2]; }
252 T&
b() {
return (*
this)[2]; }
259 const T&
a()
const {
return (*
this)[3]; }
266 T&
a() {
return (*
this)[3]; }
273 operator T ()
const {
return T(0.3*
r()+0.59*
g()+0.11*
b()); }
344 inline std::ostream&
operator<<(std::ostream& out,
const Color& c) {
345 return out << (int)c[0] <<
' ' << (
int)c[1] <<
' ' << (int)c[2];
412 double y=.299*double(rgb[0])+.587*double(rgb[1])+.114*double(rgb[2]);
423 double r(yuv[2]/.877+yuv[0]);
424 double b(yuv[1]/.492+yuv[0]);
425 double g((yuv[0]-.299*r-.114*b)/.587);
426 return RGB<T>(T(r),T(g),T(b));
const Color CYAN
Predefined color.
Definition: Color.h:323
const Color BLUE
Predefined color.
Definition: Color.h:299
RGB(const T t[3])
Constructor from C array.
Definition: Color.h:57
Vector of fixed size.
Definition: FVector.h:17
RGBA(T r, T g, T b)
Constructor with r,g,b values Constructs a RGBA of type T.
Definition: Color.h:171
const T & b() const
Read BLUE alias.
Definition: Color.h:245
const Color MAGENTA
Predefined color.
Definition: Color.h:329
RGBA< byte > AlphaColor
RGBA<byte> alias.
Definition: Color.h:354
RGBA(const FArray< T2, 3 > &x)
Constructor from RGB.
Definition: Color.h:205
const Color PURPLE
Predefined color.
Definition: Color.h:341
RGB< byte > Color
RGB<byte> alias.
Definition: Color.h:281
const Color RED
Predefined color.
Definition: Color.h:305
RGB(const FArray< T2, 4 > &x)
Constructor from RGBA.
Definition: Color.h:81
const Color WHITE
Predefined color.
Definition: Color.h:287
const AlphaColor AYELLOW
Predefined color.
Definition: Color.h:390
const Color GREEN
Predefined color.
Definition: Color.h:311
RGB(T r, T g, T b)
Constructor with r,g,b values Constructs a RGB of type T.
Definition: Color.h:49
RGBA(T r, T g, T b, T a)
Constructor with r,g,b,a values Constructs a RGBA of type T.
Definition: Color.h:161
const T & g() const
Read GREEN alias.
Definition: Color.h:102
const T & b() const
Read BLUE alias.
Definition: Color.h:116
const AlphaColor AWHITE
Predefined color.
Definition: Color.h:360
RGB< T > YUV2RGB(const FVector< double, 3 > &yuv)
YUV to RGB.
Definition: Color.h:422
const T & x() const
Read alias.
Definition: FVector.h:104
RGBA(const T t[4])
Constructor from C array.
Definition: Color.h:182
T & b()
Write BLUE alias.
Definition: Color.h:252
RED GREEN BLUE Alpha color.
Definition: Color.h:138
RGB(const FVector< T2, 3 > &x)
Constructor from other value type Constructs from RGB with different type.
Definition: Color.h:72
T & r()
Write RED alias.
Definition: Color.h:95
T & g()
Write GREEN alias.
Definition: Color.h:109
const AlphaColor ABLUE
Predefined color.
Definition: Color.h:372
RGBA(T x)
Constructor with constant value.
Definition: Color.h:154
RGBA(const FArray< T2, 4 > &x)
Constructor from other value type Constructs from RGBA with different type.
Definition: Color.h:197
friend std::ostream & operator<<(std::ostream &out, const FArray &a)
ASCII write.
Definition: FArray.h:292
Array of fixed size.
Definition: FArray.h:17
const AlphaColor ABLACK
Predefined color.
Definition: Color.h:366
const AlphaColor ARED
Predefined color.
Definition: Color.h:378
T & a()
Write alpha alias.
Definition: Color.h:266
T & b()
Write BLUE alias.
Definition: Color.h:123
const Color YELLOW
Predefined color.
Definition: Color.h:317
RGBA()
Empty constructor.
Definition: Color.h:147
const AlphaColor ACYAN
Predefined color.
Definition: Color.h:396
T & r()
Write RED alias.
Definition: Color.h:224
RGB()
Empty constructor.
Definition: Color.h:35
RGBA(const Base &x)
Copy constructor.
Definition: Color.h:189
const T & a() const
Read alpha alias.
Definition: Color.h:259
const T & r() const
Read RED alias.
Definition: Color.h:88
const T & r() const
Read RED alias.
Definition: Color.h:217
const AlphaColor AGREEN
Predefined color.
Definition: Color.h:384
const AlphaColor AMAGENTA
Predefined color.
Definition: Color.h:402
const T & g() const
Read GREEN alias.
Definition: Color.h:231
RGB(const Base &x)
Copy constructor.
Definition: Color.h:64
const T & y() const
Read alias.
Definition: FVector.h:118
Imagine++ namespace.
Definition: Array.h:7
T & g()
Write GREEN alias.
Definition: Color.h:238
RED GREEN BLUE color.
Definition: Color.h:26
const Color BLACK
Predefined color.
Definition: Color.h:293
FVector< double, 3 > RGB2YUV(const RGB< T > &rgb)
RGB to YUV.
Definition: Color.h:411
RGB(T v)
Constructor with constant value.
Definition: Color.h:42
const Color ORANGE
Predefined color.
Definition: Color.h:335