LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::rgbColor Class Reference

An alias for the rgbPixel type. More...

#include <ltiColors.h>

Inheritance diagram for lti::rgbColor:
Inheritance graph
[legend]
Collaboration diagram for lti::rgbColor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 rgbColor ()
 rgbColor (const uint32 val)
 rgbColor (const rgbPixel &other)
 rgbColor (const ubyte r, const ubyte g, const ubyte b, const ubyte d=0)
bool parseHTML (const std::string &s, bool acceptAlpha=false)
std::string makeHTML (bool getAlpha=false) const
bool parseName (const std::string &s)

Detailed Description

An alias for the rgbPixel type.

It has several useful methods though that can be used for reading color definitions from external sources.


Constructor & Destructor Documentation

lti::rgbColor::rgbColor (  )  [inline]

default constructor

lti::rgbColor::rgbColor ( const uint32  val  )  [inline]

constructor with member initialization

Per default a new rgbColor will be initialized with the given value.

Parameters:
val a 4 byte value to be assign to the three channels + dummy. Note that the order depends on the system endianness:

  • If you use little endian (for example: Intel Processor) a value of 0x00010203 means red=01,green=02 and blue=03
  • If you use big endian (for example: PowerPC Processor) a value of 0x00010203 means red=02,green=01 and blue=00 Avoid the use of this constructor if you want to maintain platform compatibility.
lti::rgbColor::rgbColor ( const rgbPixel other  )  [inline]

Upgrade constructor.

lti::rgbColor::rgbColor ( const ubyte  r,
const ubyte  g,
const ubyte  b,
const ubyte  d = 0 
) [inline]

rgb constructor

Parameters:
r 8 bit value for the red component
g 8 bit value for the green component
b 8 bit value for the blue component
d 8 bit value for the dummy byte (default value 0)

Member Function Documentation

std::string lti::rgbColor::makeHTML ( bool  getAlpha = false  )  const

Returns a HTML color definition of this color.

Parameters:
getAlpha if this is true, the returned definition will also contain the alpha channel.
bool lti::rgbColor::parseHTML ( const std::string &  s,
bool  acceptAlpha = false 
)

Parses a HTML color definition string and sets this color to the given one.

In HTML, RGB colors are defined by the following syntax:

 Color = #RRGGBB
 RR = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2}
 GG = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2}
 BB = ( 0 | 1 | 2 | ... | 9 | a | A | b | B | ... | f | F ){2}
 

For instance, "#ff0000" means red (r=255,g=0,b=0). This method also can accept an extension which also includes the alpha value as a fourth component (Color = #RRGGBBAA). If the component is not present, it will be assumed zero. If a string cannot be parsed, the value of this color object will be undefined.

Parameters:
s the HTML color definition.
acceptAlpha if this is true, the method accepts a fourth component which is interpreted as alpha value. If it is false, such a string will lead to an error.
Returns:
true if the string could be parsed, false otherwise.
bool lti::rgbColor::parseName ( const std::string &  s  ) 

Parses a color name (which colors are defined, is system dependent) and sets this color to the giveon one.

If the color name is undefined, the method will return false;

Parameters:
s the color name
Returns:
true if the name is known and defined, false otherwise.

The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:26:43 2010 for LTI-Lib by Doxygen 1.6.1