ADTF_DISPLAY_TOOLBOX  3.8.0 (ADTF 3.14.3)
cColor

Color class. More...

Inheritance diagram for cColor:
[legend]

Public Member Functions

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

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 31 of file color.h.

Constructor & Destructor Documentation

◆ cColor() [1/7]

cColor ( const IColor pColor)
inline

constructor from IColor

Parameters
[in]pColorpColor

Definition at line 50 of file color.h.

References IColor::GetAlpha(), IColor::GetBlue(), IColor::GetGreen(), and IColor::GetRed().

◆ cColor() [2/7]

cColor ( const tColor &  oColor)
inline

Constructor.

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

Definition at line 63 of file color.h.

◆ cColor() [3/7]

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 78 of file color.h.

◆ cColor() [4/7]

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 93 of file color.h.

◆ cColor() [5/7]

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 108 of file color.h.

◆ cColor() [6/7]

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.

References cColor::SetRGBA().

◆ cColor() [7/7]

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 133 of file color.h.

References cColor::SetRGBA().

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 417 of file color.h.

References cColor::cColor().

◆ 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 400 of file color.h.

References cColor::cColor().

◆ ColorFromString()

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

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

◆ GetAlpha()

tUInt8 GetAlpha ( ) const
inlinevirtual

This function returns the value for the alpha channel.

Returns
tUInt8 alpha channel

Implements IColor.

Definition at line 348 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 324 of file color.h.

◆ GetBrightness()

tUInt8 GetBrightness ( ) const
inlinevirtual

This function returns the brightness value.

Returns
brightness

Implements IColor.

Definition at line 360 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 300 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 276 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 231 of file color.h.

References IImage::PF_BGRA_8888.

Referenced by cColor::operator tUInt32().

◆ GetRGBA() [2/2]

tUInt32 GetRGBA ( tInt  oPixelFormat) const

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

◆ operator const IColor *()

operator const IColor * ( ) const
inlineexplicit

instance of IColor

Returns
object

Definition at line 455 of file color.h.

◆ operator IColor *()

operator IColor * ( )
inlineexplicit

instance of IColor

Returns
object

Definition at line 445 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 252 of file color.h.

References cColor::GetRGBA(), and IImage::PF_RGBA_8888.

◆ 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 387 of file color.h.

References cColor::cColor().

◆ 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 373 of file color.h.

References cColor::cColor().

◆ 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 193 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 155 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 175 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 336 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 312 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 288 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 264 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 207 of file color.h.

References IImage::PF_BGRA_8888.

Referenced by cColor::cColor().

◆ SetRGBA() [2/2]

tVoid SetRGBA ( tUInt32  nRGBA,
tInt  oPixelFormat 
)

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