51 this->nRed = pColor->
GetRed();
53 this->nBlue = pColor->
GetBlue();
64 this->nRed = oColor.nRed;
65 this->nGreen = oColor.nGreen;
66 this->nBlue = oColor.nBlue;
67 this->nAlpha = oColor.nAlpha;
77 cColor(tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal = 255)
79 this->nRed = (tUInt8) nRedLocal;
80 this->nGreen = (tUInt8) nGreenLocal;
81 this->nBlue = (tUInt8) nBlueLocal;
82 this->nAlpha = (tUInt8) nAlphaLocal;
92 cColor(tUInt8 nRed, tUInt8 nGreen, tUInt8 nBlue, tUInt8 nAlpha = 255)
94 this->nRed = (tUInt8) nRed;
95 this->nGreen = (tUInt8) nGreen;
96 this->nBlue = (tUInt8) nBlue;
97 this->nAlpha = (tUInt8) nAlpha;
107 cColor(tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha = 1.0f)
109 this->nRed = (tUInt8) (fRed * 255.0f);
110 this->nGreen = (tUInt8) (fGreen * 255.0f);
111 this->nBlue = (tUInt8) (fBlue * 255.0f);
112 this->nAlpha = (tUInt8) (fAlpha * 255.0f);
160 tVoid
Set(tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal = 255)
162 this->nRed = (tUInt8) nRedLocal;
163 this->nGreen = (tUInt8) nGreenLocal;
164 this->nBlue = (tUInt8) nBlueLocal;
165 this->nAlpha = (tUInt8) nAlphaLocal;
180 tVoid
Set(tUInt8 nRedLocal, tUInt8 nGreenLocal, tUInt8 nBlueLocal, tUInt8 nAlphaLocal = 255)
182 this->nRed = nRedLocal;
183 this->nGreen = nGreenLocal;
184 this->nBlue = nBlueLocal;
185 this->nAlpha = nAlphaLocal;
198 tVoid
Set(tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha = 1.0f)
200 this->nRed = (tUInt8) (fRed * 255.0f);
201 this->nGreen = (tUInt8) (fGreen * 255.0f);
202 this->nBlue = (tUInt8) (fBlue * 255.0f);
203 this->nAlpha = (tUInt8) (fAlpha * 255.0f);
227 tVoid
SetRGBA(tUInt32 nRGBA, tInt oPixelFormat)
229 switch (oPixelFormat)
232 nBlue = (tUInt8) ((nRGBA & 0xf) << 4);
233 nGreen = (tUInt8) (nRGBA & 0xf0);
234 nRed = (tUInt8) ((nRGBA & 0xf00) >> 4);
239 nBlue = (tUInt8) ((nRGBA & 0xf) << 4);
240 nGreen = (tUInt8) (nRGBA & 0xf0);
241 nRed = (tUInt8) ((nRGBA & 0xf00) >> 4);
242 nAlpha = (tUInt8) ((nRGBA & 0xf000) >> 8);
246 nBlue = (tUInt8) ((nRGBA & 0x1f) << 3);
247 nGreen = (tUInt8) ((nRGBA & 0x3e0) >> 2);
248 nRed = (tUInt8) ((nRGBA & 0x7c00) >> 7);
253 nBlue = (tUInt8) ((nRGBA & 0x1f) << 3);
254 nGreen = (tUInt8) ((nRGBA & 0x7e0) >> 3);
255 nRed = (tUInt8) ((nRGBA & 0xf800) >> 8);
260 nBlue = ((tUInt8*) &nRGBA)[0];
261 nGreen = ((tUInt8*) &nRGBA)[1];
262 nRed = ((tUInt8*) &nRGBA)[2];
267 nBlue = ((tUInt8*) &nRGBA)[2];
268 nGreen = ((tUInt8*) &nRGBA)[1];
269 nRed = ((tUInt8*) &nRGBA)[0];
274 nBlue = ((tUInt8*) &nRGBA)[0];
275 nGreen = ((tUInt8*) &nRGBA)[1];
276 nRed = ((tUInt8*) &nRGBA)[2];
277 nAlpha = ((tUInt8*) &nRGBA)[3];
281 nBlue = ((tUInt8*) &nRGBA)[2];
282 nGreen = ((tUInt8*) &nRGBA)[1];
283 nRed = ((tUInt8*) &nRGBA)[0];
284 nAlpha = ((tUInt8*) &nRGBA)[3];
288 nBlue = ((tUInt8*) &nRGBA)[1];
289 nGreen = ((tUInt8*) &nRGBA)[2];
290 nRed = ((tUInt8*) &nRGBA)[3];
291 nAlpha = ((tUInt8*) &nRGBA)[0];
295 nBlue = ((tUInt8*) &nRGBA)[3];
296 nGreen = ((tUInt8*) &nRGBA)[2];
297 nRed = ((tUInt8*) &nRGBA)[1];
298 nAlpha = ((tUInt8*) &nRGBA)[0];
327 tUInt8* pResult = (tUInt8*) &nResult;
329 switch (oPixelFormat)
332 nResult = tUInt32(nBlue >> 4) | tUInt32(nGreen & 0xf0) | tUInt32((nRed & 0xf0) << 4);
336 nResult = tUInt32(nBlue >> 4) | tUInt32(nGreen & 0xf0) | tUInt32((nRed & 0xf0) << 4) |
337 tUInt32((nAlpha & 0xf0) << 8);
341 nResult = tUInt32(nBlue >> 3) | tUInt32((nGreen & 0xf8) << 2) | tUInt32((nRed & 0xf8) << 7);
345 nResult = tUInt32(nBlue >> 3) | tUInt32((nGreen & 0xfc) << 3) | tUInt32((nRed & 0xf8) << 8);
413 this->nRed = nRedValue;
437 this->nGreen = nGreenValue;
461 this->nBlue = nBlueValue;
485 this->nAlpha = nAlphaValue;
509 return (tUInt8) ((116 * nRed + 602 * nGreen + 306 * nBlue) >> 10);
522 return cColor(c.nRed * nAlpha / 255, c.nGreen * nAlpha / 255, c.nBlue * nAlpha / 255);
534 return cColor(c.nRed * fAlpha, c.nGreen * fAlpha, c.nBlue * fAlpha);
547 tUInt8 nInvAlpha = (tUInt8) (255 - nAlpha);
549 return cColor((c1.nRed * nAlpha + c2.nRed * nInvAlpha) / 255,
550 (c1.nGreen * nAlpha + c2.nGreen * nInvAlpha) / 255,
551 (c1.nBlue * nAlpha + c2.nBlue * nInvAlpha) / 255);
564 tUInt8 nAlpha = (tUInt8) (fAlpha * 255.0f);
565 tUInt8 nInvAlpha = (tUInt8) (255 - nAlpha);
567 return cColor((c1.nRed * nAlpha + c2.nRed * nInvAlpha) / 255,
568 (c1.nGreen * nAlpha + c2.nGreen * nInvAlpha) / 255,
569 (c1.nBlue * nAlpha + c2.nBlue * nInvAlpha) / 255);
585 RETURN_IF_POINTER_NULL(strColor);
587 if (strColor[0] !=
'#')
589 RETURN_ERROR(ERR_INVALID_ARG);
596 for (tUInt nIdx = 1; nIdx < strlen(strColor); nIdx++)
599 tChar cChar = strColor[nIdx];
612 case '9': nVal = cChar -
'0';
break;
618 case 'f': nVal = cChar -
'a' + 10;
break;
624 case 'F': nVal = cChar -
'A' + 10;
break;
625 default: RETURN_ERROR(ERR_INVALID_ARG);
630 case 1: r = nVal * 16;
break;
631 case 2: r = r + nVal;
break;
632 case 3: g = nVal * 16;
break;
633 case 4: g = g + nVal;
break;
634 case 5: b = nVal * 16;
break;
635 case 6: b = b + nVal;
break;
636 case 7: a = nVal * 16;
break;
637 case 8: a = a + nVal;
break;
641 oColor.
Set(r, g, b, a);
652 return static_cast<IColor*
>(
this);
662 return static_cast<const IColor*
>(
this);
cColor()
default constructor
Interface for color representation.
virtual tUInt8 GetRed() const =0
Returns the value for the red channel.
virtual tUInt8 GetAlpha() const =0
This function returns the value for the alpha channel.
virtual tUInt8 GetBlue() const =0
Returns the value for the blue channel.
virtual tUInt8 GetGreen() const =0
Returns the value for the green channel.
@ PF_RGB_888
24 bit RGB (R: 8 bit, G: 8 bit, B: 8 bit) - default format for 24 bpp
@ PF_RGBA_8888
32 bit RGBA (R: 8 bit, G: 8 bit, B: 8 bit, A: 8 bit) with alpha value - default format for 32 bpp
@ PF_RGB_555
15 bit RGB (R: 5 bit, G: 5 bit, B: 5 bit) - default format for 16 bpp
@ PF_RGB_565
16 bit RGB (R: 5 bit, G: 6 bit, B: 5 bit)
@ PF_BGRA_8888
32 bit BGRA (B: 8 bit, G: 8 bit, R: 8 bit, A: 8 bit) with alpha value - inverted RGB + A
@ PF_ARGB_8888
32 bit ARGB (A: 8 bit, R: 8 bit, G: 8 bit, B: 8 bit) with alpha value
@ PF_ABGR_8888
32 bit ABGR (A: 8 bit, B: 8 bit, G: 8 bit, R: 8 bit) with alpha value - inverted RGBA
@ PF_RGB_444
12 bit RGB (R: 4 bit, G: 4 bit, B: 4 bit)
@ PF_BGR_888
24 bit BGR (B: 8 bit, G: 8 bit, R: 8 bit) - inverted RGB
@ PF_RGBA_4444
16 bit RGBA (R: 4 bit, G: 4 bit, B: 4 bit, A: 4 bit) with alpha value
static cColor Blend(const cColor &c1, const cColor &c2, tFloat32 fAlpha)
blends two colors with an alpha channel
tVoid SetAlpha(tUInt8 nAlphaValue)
Sets the value of the alpha channel.
tVoid SetBlue(tUInt8 nBlueValue)
Sets the value of the blue channel.
static const cColor Yellow
definition of color yellow
tVoid SetRGBA(tUInt32 nRGBA, tInt oPixelFormat)
Method which decodes the rgba-values stored in nRGBA depending on the given pixelformat.
static const cColor Red
definition of color red
tVoid Release()
Releases this color.
cColor(tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha=1.0f)
constructor with several init parameters.
tUInt8 GetBlue() const
Returns the value for the green channel.
tUInt8 GetRed() const
Returns the value for the red channel.
tUInt8 GetBrightness() const
This function returns the brightness value.
cColor(const IColor *pColor)
constructor from IColor
static const cColor Purple
definition of color purple
static const cColor White
definition of color white
tVoid SetGreen(tUInt8 nGreenValue)
Sets the value of the green channel.
tUInt8 GetAlpha() const
This function returns the value for the alpha channel.
tVoid Set(tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal=255)
Method to set color and transparency information.
static cColor Scale(const cColor &c, tFloat32 fAlpha)
scales a color with an alpha channel
tVoid SetRGBA(tUInt32 nRGBA)
method to set color and transparency with a combined parameter (3 color channels and the alphachannel...
cColor(const tColor &oColor)
Constructor.
tUInt32 GetRGBA(tInt oPixelFormat) const
Gets a four byte balue containing the current rgba-values encoded in the given pixel format.
tVoid SetRed(tUInt8 nRedValue)
Sets the value of the red channel.
tVoid Set(tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha=1.0f)
Method to set color and transparency information.
static cColor Scale(const cColor &c, tInt nAlpha)
scales a color with an alpha channel
cColor(tUInt8 nRed, tUInt8 nGreen, tUInt8 nBlue, tUInt8 nAlpha=255)
constructor with several init parameters.
static cColor Blend(const cColor &c1, const cColor &c2, tInt nAlpha)
blends two colors with an alpha channel
static const cColor Black
definition of color black
static const cColor Blue
definition of color blue
cColor(tUInt32 nRGBA)
Constructor with a bitfield containing the encoded rgba-values.
static const cColor Cyan
definition of color cyan
tVoid Set(tUInt8 nRedLocal, tUInt8 nGreenLocal, tUInt8 nBlueLocal, tUInt8 nAlphaLocal=255)
Method to set color and transparency information.
tUInt32 GetRGBA() const
Gets a four Byte value containing the 3 color channels and the alphachannel.
cColor()
default constructor
cColor(tUInt32 nRGBA, tInt oPixelFormat)
Constructor with a bitfield containing the encoded rgba-values and another parameter which describes ...
cColor(tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal=255)
constructor with several init parameters.
static const cColor Green
definition of color green
tUInt8 GetGreen() const
Returns the value for the green channel.
static tResult ColorFromString(const tChar *strColor, cColor &oColor)
Converts a hexadecimal color value into a cColor object The input format is like the HTML color defin...
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Namespace for functionality provided by the Display Toolbox.