ADTF Display Toolbox
Loading...
Searching...
No Matches
cColor

Color class. More...

#include <color.h>

Inheritance diagram for cColor:
[legend]

Public Member Functions

 cColor ()
 default constructor
 
 cColor (const IColor *pColor)
 constructor from IColor
 
 cColor (const tColor &oColor)
 Constructor.
 
 cColor (tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal=255)
 constructor with several init parameters.
 
 cColor (tUInt8 nRed, tUInt8 nGreen, tUInt8 nBlue, tUInt8 nAlpha=255)
 constructor with several init parameters.
 
 cColor (tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha=1.0f)
 constructor with several init parameters.
 
 cColor (tUInt32 nRGBA)
 Constructor with a bitfield containing the encoded rgba-values.
 
 cColor (tUInt32 nRGBA, tInt oPixelFormat)
 Constructor with a bitfield containing the encoded rgba-values and another parameter which describes the format.
 
tVoid Release ()
 Releases this color.
 
tVoid Set (tInt nRedLocal, tInt nGreenLocal, tInt nBlueLocal, tInt nAlphaLocal=255)
 Method to set color and transparency information.
 
tVoid Set (tUInt8 nRedLocal, tUInt8 nGreenLocal, tUInt8 nBlueLocal, tUInt8 nAlphaLocal=255)
 Method to set color and transparency information.
 
tVoid Set (tFloat32 fRed, tFloat32 fGreen, tFloat32 fBlue, tFloat32 fAlpha=1.0f)
 Method to set color and transparency information.
 
tVoid SetRGBA (tUInt32 nRGBA)
 method to set color and transparency with a combined parameter (3 color channels and the alphachannel)
 
tVoid SetRGBA (tUInt32 nRGBA, tInt oPixelFormat)
 Method which decodes the rgba-values stored in nRGBA depending on the given pixelformat.
 
tUInt32 GetRGBA () const
 Gets a four Byte value containing the 3 color channels and the alphachannel.
 
tUInt32 GetRGBA (tInt oPixelFormat) const
 Gets a four byte balue containing the current rgba-values encoded in the given pixel format.
 
 operator tUInt32 ()
 Casting operator which converts an RGBA structure into an tUInt32 For conversion, the format PF_RGBA_8888 is assumed.
 
tVoid SetRed (tUInt8 nRedValue)
 Sets the value of the red channel.
 
tUInt8 GetRed () const
 Returns the value for the red channel.
 
tVoid SetGreen (tUInt8 nGreenValue)
 Sets the value of the green channel.
 
tUInt8 GetGreen () const
 Returns the value for the green channel.
 
tVoid SetBlue (tUInt8 nBlueValue)
 Sets the value of the blue channel.
 
tUInt8 GetBlue () const
 Returns the value for the green channel.
 
tVoid SetAlpha (tUInt8 nAlphaValue)
 Sets the value of the alpha channel.
 
tUInt8 GetAlpha () const
 This function returns the value for the alpha channel.
 
tUInt8 GetBrightness () const
 This function returns the brightness value.
 
 operator IColor * ()
 instance of IColor
 
 operator const IColor * () const
 instance of IColor
 
- Public Member Functions inherited from IColor
virtual ~IColor ()
 virtual destructor to ensure proper cleanup.
 

Static Public Member Functions

static cColor Scale (const cColor &c, tInt nAlpha)
 scales a color with an alpha channel
 
static cColor Scale (const cColor &c, tFloat32 fAlpha)
 scales a color with an alpha channel
 
static cColor Blend (const cColor &c1, const cColor &c2, tInt nAlpha)
 blends two colors with an alpha channel
 
static cColor Blend (const cColor &c1, const cColor &c2, tFloat32 fAlpha)
 blends two colors with an alpha 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 definition (red: #ff0000, green: #00ff00, blue: #0000ff...) The leading # must exist.
 

Static Public Attributes

static const cColor Black
 definition of color black
 
static const cColor White
 definition of color white
 
static const cColor Red
 definition of color red
 
static const cColor Green
 definition of color green
 
static const cColor Blue
 definition of color blue
 
static const cColor Yellow
 definition of color yellow
 
static const cColor Cyan
 definition of color cyan
 
static const cColor Purple
 definition of color purple
 

Detailed Description

Color class.

Definition at line 30 of file color.h.

Constructor & Destructor Documentation

◆ cColor() [1/8]

cColor ( )
inline

default constructor

Definition at line 36 of file color.h.

◆ cColor() [2/8]

cColor ( const IColor * pColor)
inline

constructor from IColor

Parameters
[in]pColorpColor

Definition at line 49 of file color.h.

◆ cColor() [3/8]

cColor ( const tColor & oColor)
inline

Constructor.

Parameters
[in]oColor- struct, containing blue, green, red and alpha channel

Definition at line 62 of file color.h.

◆ cColor() [4/8]

cColor ( tInt nRedLocal,
tInt nGreenLocal,
tInt nBlueLocal,
tInt nAlphaLocal = 255 )
inline

constructor with several init parameters.

Allowed values 0..255

Parameters
[in]nRedLocalred channel
[in]nGreenLocalgreen channel
[in]nBlueLocalblue channel
[in]nAlphaLocalalpha channel

Definition at line 77 of file color.h.

◆ cColor() [5/8]

cColor ( tUInt8 nRed,
tUInt8 nGreen,
tUInt8 nBlue,
tUInt8 nAlpha = 255 )
inline

constructor with several init parameters.

Allowed values 0..255

Parameters
[in]nRedred channel
[in]nGreengreen channel
[in]nBlueblue channel
[in]nAlphaalpha channel

Definition at line 92 of file color.h.

◆ cColor() [6/8]

cColor ( tFloat32 fRed,
tFloat32 fGreen,
tFloat32 fBlue,
tFloat32 fAlpha = 1.0f )
inline

constructor with several init parameters.

Allowed values 0 .. 1.0

Parameters
[in]fRedred channel
[in]fGreengreen channel
[in]fBlueblue channel
[in]fAlphaalpha channel

Definition at line 107 of file color.h.

◆ cColor() [7/8]

cColor ( tUInt32 nRGBA)
inline

Constructor with a bitfield containing the encoded rgba-values.

The default format is PF_BGRA_8888

Parameters
[in]nRGBAcombined parameter, first byte represents red, second green, third blue and the last the alpha channel
See also
SetRGBA

Definition at line 122 of file color.h.

◆ cColor() [8/8]

cColor ( tUInt32 nRGBA,
tInt oPixelFormat )
inline

Constructor with a bitfield containing the encoded rgba-values and another parameter which describes the format.

Parameters
[in]nRGBAcolor value. The color positions and sizes are defined with the second parameter oPixelFormat
[in]oPixelFormatcombined parameter. The color positions of nRGBA and sizes are defined with the second parameter oPixelFormat
See also
SetRGBA

Definition at line 135 of file color.h.

Member Function Documentation

◆ Blend() [1/2]

static cColor Blend ( const cColor & c1,
const cColor & c2,
tFloat32 fAlpha )
inlinestatic

blends two colors with an alpha channel

Parameters
[in]c1first color
[in]c2second color
[in]fAlphaalpha channel
Returns
blended color

Definition at line 562 of file color.h.

◆ Blend() [2/2]

static cColor Blend ( const cColor & c1,
const cColor & c2,
tInt nAlpha )
inlinestatic

blends two colors with an alpha channel

Parameters
[in]c1first color
[in]c2second color
[in]nAlphaalpha channel
Returns
blended color

Definition at line 545 of file color.h.

◆ ColorFromString()

static tResult ColorFromString ( const tChar * strColor,
cColor & oColor )
inlinestatic

Converts a hexadecimal color value into a cColor object The input format is like the HTML color definition (red: #ff0000, green: #00ff00, blue: #0000ff...) The leading # must exist.

If a fourth byte is provided than this will be treaded as alpha value.

Parameters
strColor[in] The string which contains the color definition (#rrggbbaa, whereby aa is optional)
oColor[out] The passed color receives the result
Returns
ERR_POINTER if strColor is NULL,
ERR_INVALID_ARG if the first character is not a '#' ERR_INVALID_ARG if an unexpected character was found RETURN_NOERROR if succeeded

Definition at line 583 of file color.h.

◆ GetAlpha()

tUInt8 GetAlpha ( ) const
inlinevirtual

This function returns the value for the alpha channel.

Returns
tUInt8 alpha channel

Implements IColor.

Definition at line 495 of file color.h.

◆ GetBlue()

tUInt8 GetBlue ( ) const
inlinevirtual

Returns the value for the green channel.

Returns
tUInt8 green channel

Implements IColor.

Definition at line 471 of file color.h.

◆ GetBrightness()

tUInt8 GetBrightness ( ) const
inlinevirtual

This function returns the brightness value.

Returns
brightness

Implements IColor.

Definition at line 507 of file color.h.

◆ GetGreen()

tUInt8 GetGreen ( ) const
inlinevirtual

Returns the value for the green channel.

Returns
tUInt8 green channel

Implements IColor.

Definition at line 447 of file color.h.

◆ GetRed()

tUInt8 GetRed ( ) const
inlinevirtual

Returns the value for the red channel.

Returns
tUInt8 red channel

Implements IColor.

Definition at line 423 of file color.h.

◆ GetRGBA() [1/2]

tUInt32 GetRGBA ( ) const
inlinevirtual

Gets a four Byte value containing the 3 color channels and the alphachannel.

Returns
tUInt32 combined return value, first byte represents red, second green, third blue and the last the alpha channel
Remarks
This function is not platform independent.

Implements IColor.

Definition at line 312 of file color.h.

◆ GetRGBA() [2/2]

tUInt32 GetRGBA ( tInt oPixelFormat) const
inline

Gets a four byte balue containing the current rgba-values encoded in the given pixel format.

Parameters
oPixelFormat[in] one of PF_RGB_444 | PF_RGBA_4444 | PF_RGB_555 | PF_RGB_565 | PF_RGB_888 | PF_BGR_888 | PF_RGBA_8888 | PF_BGRA_8888 | PF_ARGB_8888 | PF_ABGR_8888 All values have to be preceeded with adtf_util::IImage::
Returns
the encoded value containing the current rgba-values or 0 if the format is not supported

Definition at line 324 of file color.h.

◆ operator const IColor *()

operator const IColor * ( ) const
inlineexplicit

instance of IColor

Returns
object

Definition at line 660 of file color.h.

◆ operator IColor *()

operator IColor * ( )
inlineexplicit

instance of IColor

Returns
object

Definition at line 650 of file color.h.

◆ operator tUInt32()

operator tUInt32 ( )
inline

Casting operator which converts an RGBA structure into an tUInt32 For conversion, the format PF_RGBA_8888 is assumed.

Better use GetRGBA(tInt oPixelFormat)

Returns
32 bit representation of the current color

Definition at line 399 of file color.h.

◆ Release()

tVoid Release ( )
inlinevirtual

Releases this color.

Implements IColor.

Definition at line 143 of file color.h.

◆ Scale() [1/2]

static cColor Scale ( const cColor & c,
tFloat32 fAlpha )
inlinestatic

scales a color with an alpha channel

Parameters
[in]cgiven color
[in]fAlphagiven alpha channel
Returns
scaled color

Definition at line 532 of file color.h.

◆ Scale() [2/2]

static cColor Scale ( const cColor & c,
tInt nAlpha )
inlinestatic

scales a color with an alpha channel

Parameters
[in]cgiven color
[in]nAlphagiven alpha channel
Returns
scaled color

Definition at line 520 of file color.h.

◆ Set() [1/3]

tVoid Set ( tFloat32 fRed,
tFloat32 fGreen,
tFloat32 fBlue,
tFloat32 fAlpha = 1.0f )
inline

Method to set color and transparency information.

Allowed values are 0 to 1

Parameters
[in]fRedred channel
[in]fGreengreen channel
[in]fBlueblue channel
[in]fAlphatransparency channel
Returns
void

Definition at line 198 of file color.h.

◆ Set() [2/3]

tVoid Set ( tInt nRedLocal,
tInt nGreenLocal,
tInt nBlueLocal,
tInt nAlphaLocal = 255 )
inline

Method to set color and transparency information.

Allowed values are 0 to 255

Parameters
[in]nRedLocalred channel
[in]nGreenLocalgreen channel
[in]nBlueLocalblue channel
[in]nAlphaLocaltransparency channel
Returns
void

Definition at line 160 of file color.h.

◆ Set() [3/3]

tVoid Set ( tUInt8 nRedLocal,
tUInt8 nGreenLocal,
tUInt8 nBlueLocal,
tUInt8 nAlphaLocal = 255 )
inline

Method to set color and transparency information.

Allowed values are 0 to 255

Parameters
[in]nRedLocalred channel
[in]nGreenLocalgreen channel
[in]nBlueLocalblue channel
[in]nAlphaLocaltransparency channel
Returns
void

Definition at line 180 of file color.h.

◆ SetAlpha()

tVoid SetAlpha ( tUInt8 nAlphaValue)
inlinevirtual

Sets the value of the alpha channel.

Parameters
nAlphaValue[in] value for the alpha channel
Returns
void

Implements IColor.

Definition at line 483 of file color.h.

◆ SetBlue()

tVoid SetBlue ( tUInt8 nBlueValue)
inlinevirtual

Sets the value of the blue channel.

Parameters
nBlueValue[in] value for the blue channel
Returns
void

Implements IColor.

Definition at line 459 of file color.h.

◆ SetGreen()

tVoid SetGreen ( tUInt8 nGreenValue)
inlinevirtual

Sets the value of the green channel.

Parameters
nGreenValue[in] value for the green channel
Returns
void

Implements IColor.

Definition at line 435 of file color.h.

◆ SetRed()

tVoid SetRed ( tUInt8 nRedValue)
inlinevirtual

Sets the value of the red channel.

Parameters
nRedValue[in] value for the red channel
Returns
void

Implements IColor.

Definition at line 411 of file color.h.

◆ SetRGBA() [1/2]

tVoid SetRGBA ( tUInt32 nRGBA)
inlinevirtual

method to set color and transparency with a combined parameter (3 color channels and the alphachannel)

Parameters
[in]nRGBAcombined parameter, first byte represents red, second green, third blue and the last the alpha channel
Returns
tVoid
Remarks
This function is not platform independent.

Implements IColor.

Definition at line 213 of file color.h.

◆ SetRGBA() [2/2]

tVoid SetRGBA ( tUInt32 nRGBA,
tInt oPixelFormat )
inline

Method which decodes the rgba-values stored in nRGBA depending on the given pixelformat.

Parameters
nRGBA[in] Bitfield containing the encoded rgba-data
oPixelFormat[in] one of PF_RGB_444 | PF_RGBA_4444 | PF_RGB_555 | PF_RGB_565 | PF_RGB_888 | PF_BGR_888 | PF_RGBA_8888 | PF_BGRA_8888 | PF_ARGB_8888 | PF_ABGR_8888 All values have to be preceeded with adtf_util::IImage
Returns
tVoid
Remarks
If an unsupported format is passed to this method the current stored rgba-values are kept unchanged

Definition at line 227 of file color.h.

Member Data Documentation

◆ Black

const cColor Black
inlinestatic

definition of color black

Definition at line 666 of file color.h.

◆ Blue

const cColor Blue
inlinestatic

definition of color blue

Definition at line 670 of file color.h.

◆ Cyan

const cColor Cyan
inlinestatic

definition of color cyan

Definition at line 672 of file color.h.

◆ Green

const cColor Green
inlinestatic

definition of color green

Definition at line 669 of file color.h.

◆ Purple

const cColor Purple
inlinestatic

definition of color purple

Definition at line 673 of file color.h.

◆ Red

const cColor Red
inlinestatic

definition of color red

Definition at line 668 of file color.h.

◆ White

const cColor White
inlinestatic

definition of color white

Definition at line 667 of file color.h.

◆ Yellow

const cColor Yellow
inlinestatic

definition of color yellow

Definition at line 671 of file color.h.