85 memcpy(temp.u8ptr(), &val, 4*
sizeof(ito::uint8));
89 Rgba32(
const uint8 &a,
const uint8 &r,
const uint8 &g,
const uint8 &b)
116 b =
static_cast<uint8
>(std::min<int16>(b + rhs.b, 255));
117 g =
static_cast<uint8
>(std::min<int16>(g + rhs.g, 255));
118 r =
static_cast<uint8
>(std::min<int16>(r + rhs.r, 255));
119 a =
static_cast<uint8
>(std::min<int16>(a + rhs.a, 255));
137 b =
static_cast<uint8
>(std::max<int16>(b - rhs.b, 0));
138 g =
static_cast<uint8
>(std::max<int16>(g - rhs.g, 0));
139 r =
static_cast<uint8
>(std::max<int16>(r - rhs.r, 0));
140 a =
static_cast<uint8
>(std::max<int16>(a - rhs.a, 0));
150 b =
static_cast<uint8
>(b * rhs.b / 255);
151 g =
static_cast<uint8
>(g * rhs.g / 255);
152 r =
static_cast<uint8
>(r * rhs.r / 255);
153 a =
static_cast<uint8
>(a * rhs.a / 255);
164 if (grayFactor < 0.0)
166 throw std::runtime_error(
"Multiplication factor must be >= 0.0");
168 unsigned int t =
static_cast<unsigned int>(b * grayFactor);
169 b =
static_cast<uint8
>(t <= 255 ? t : 255);
170 t =
static_cast<unsigned int>(g * grayFactor);
171 g =
static_cast<uint8
>(t <= 255 ? t : 255);
172 t =
static_cast<unsigned int>(r * grayFactor);
173 r =
static_cast<uint8
>(t <= 255 ? t : 255);
179 if(rhs.b == 0 || rhs.g == 0 || rhs.r == 0 || rhs.a == 0)
181 throw std::runtime_error(
"Division by zero not allowed for rgba32-values");
183 b =
static_cast<uint8
>(std::min<int16>((b * (ito::int16)255) / rhs.b, 255));
184 g =
static_cast<uint8
>(std::min<int16>((g * (ito::int16)255) / rhs.g, 255));
185 r =
static_cast<uint8
>(std::min<int16>((r * (ito::int16)255) / rhs.r, 255));
186 a =
static_cast<uint8
>(std::min<int16>((a * (ito::int16)255) / rhs.a, 255));
227 return (b == rhs.b) && (g == rhs.g) && (r == rhs.r && (a == rhs.a));
232 return (b != rhs.b) || (g != rhs.g) || (r != rhs.r || (a != rhs.a));
237 return static_cast<float32
>(0.299 * r + 0.587 * g + 0.114 * b);
240 uint8& alpha() {
return a;};
246 uint8
red()
const {
return r;};
248 uint8
blue()
const {
return b;};
251 uint32
argb()
const {
return rgba;};
254 uint8* u8ptr() {
return ((uint8*)(&rgba));}
270 items[_COLOR] = gray;
292 items[_COLOR] = rhs.items[_COLOR];
297 items[_COLOR] =
static_cast<uint8
>(std::min<int16>(items[_COLOR] + rhs.items[_COLOR], 255));
303 items[_COLOR] = rhs.items[_COLOR];
309 items[_COLOR] = ((
unsigned char*)&rhs)[_COLOR];
315 items[_COLOR] =
static_cast<uint8
>(std::max<int16>(items[_COLOR] - rhs.items[_COLOR], 0));
321 items[_COLOR] =
static_cast<uint8
>(items[_COLOR] * rhs.items[_COLOR] / 255);
327 if(rhs.items[_COLOR] == 0)
329 throw std::runtime_error(
"Division by zero not allowed for rgba32-values");
331 items[_COLOR] =
static_cast<uint8
>(std::min<int16>((items[_COLOR] * (ito::int16)255)/ rhs.items[_COLOR], 255));
365 return items[_COLOR] == rhs.items[_COLOR];
370 return items[_COLOR] != rhs.items[_COLOR];
375 return (items[_COLOR] < rhs.items[_COLOR]);
380 return (items[_COLOR] < rhs.items[_COLOR]);
383 inline float32 gray()
const {
return static_cast<float32
> (items[_COLOR]);};
385 uint8&
value() {
return items[_COLOR];};
386 uint8
value()
const {
return items[_COLOR];};
389 typedef RGBChannel<Rgba32::RGBA_A> AlphaChannel;
390 typedef RGBChannel<Rgba32::RGBA_R> RedChannel;
391 typedef RGBChannel<Rgba32::RGBA_G> GreenChannel;
392 typedef RGBChannel<Rgba32::RGBA_B> BlueChannel;
RGBChannel & operator/=(const RGBChannel &rhs)
Definition color.h:325
bool operator<(const RGBChannel &rhs) const
Definition color.h:373
RGBChannel & operator-=(const RGBChannel &rhs)
Definition color.h:313
RGBChannel & operator*=(const RGBChannel &rhs)
Definition color.h:319
bool operator>(const RGBChannel &rhs) const
Definition color.h:378
RGBChannel()
Definition color.h:261
uint8 & value()
Definition color.h:385
bool operator==(const RGBChannel &rhs) const
Definition color.h:363
RGBChannel operator/(const RGBChannel &second) const
Definition color.h:356
RGBChannel operator+(const RGBChannel &second) const
Definition color.h:335
RGBChannel operator-(const RGBChannel &second) const
Definition color.h:342
RGBChannel & operator+=(const RGBChannel &rhs)
Definition color.h:295
RGBChannel & operator=(const RGBChannel &rhs)
Definition color.h:301
RGBChannel(const RGBChannel &rhs)
Definition color.h:288
uint8 value() const
Definition color.h:386
RGBChannel(const uint8 gray)
Definition color.h:266
bool operator!=(const RGBChannel &rhs) const
Definition color.h:368
RGBChannel operator*(const RGBChannel &second) const
Definition color.h:349
This class implements basic functionality for color handling in itom. \detail This class implements A...
Definition color.h:47
uint8 blue() const
Definition color.h:248
Rgba32 operator-(const Rgba32 &second) const
Definition color.h:197
uint32 & argb()
Definition color.h:250
bool operator==(const Rgba32 &rhs) const
Definition color.h:225
Rgba32(const Rgba32 &rhs)
Definition color.h:109
Rgba32(const uint8 &a, const uint8 &r, const uint8 &g, const uint8 &b)
Definition color.h:89
Rgba32 & operator*=(const Rgba32 &rhs)
Multiplication by another Rgba32 value.
Definition color.h:148
uint8 alpha() const
Definition color.h:245
RGBSelectionFlags
Definition color.h:51
@ RGBA_B
blue
Definition color.h:52
@ RGBA_R
red
Definition color.h:54
@ RGBA_Y
gray
Definition color.h:56
@ RGBA_G
green
Definition color.h:53
@ RGBA_A
alpha
Definition color.h:55
Rgba32 operator*(const Rgba32 &second) const
Definition color.h:204
float32 gray() const
Definition color.h:235
static Rgba32 fromUnsignedLong(const uint32 val)
static constructor to create Rgba32 from uint32 containing the values argb
Definition color.h:82
Rgba32 & operator-=(const Rgba32 &rhs)
Definition color.h:135
Rgba32 & operator=(const Rgba32 &rhs)
Definition color.h:123
uint8 & red()
Definition color.h:241
uint8 red() const
Definition color.h:246
uint32 argb() const
Definition color.h:251
Rgba32 & operator/=(const Rgba32 &rhs)
Definition color.h:177
Rgba32 & operator+=(const Rgba32 &rhs)
Definition color.h:114
bool operator!=(const Rgba32 &rhs) const
Definition color.h:230
Rgba32 operator+(const Rgba32 &second) const
Definition color.h:190
Rgba32 operator/(const Rgba32 &second) const
Definition color.h:218
uint32 * u32ptr()
Definition color.h:253
Rgba32()
Definition color.h:60
uint8 & blue()
Definition color.h:243
uint8 & green()
Definition color.h:242
Rgba32(const uint8 gray)
Constructor which will set color channels to gray uint8 and alpha to 255.
Definition color.h:101
uint8 green() const
Definition color.h:247
Definition typeDefs.h:143
Definition apiFunctionsGraph.cpp:40