26 #ifndef __TERRALIB_COLOR_INTERNAL_RGBACOLOR_H 27 #define __TERRALIB_COLOR_INTERNAL_RGBACOLOR_H 30 #include "../core/utils/HexUtils.h" 190 void getRgba(
int* r,
int* g,
int* b,
int* a=0)
const;
210 void setColor(
const std::string& hexColor);
232 void setColor(
int r,
int g,
int b,
int a=255);
266 :
m_rgba((a << 24) + (r << 16) + (g << 8) + b)
268 assert(r >= 0 && r <= 255);
269 assert(g >= 0 && g <= 255);
270 assert(b >= 0 && b <= 255);
271 assert(a >= 0 && a <= 255);
309 return (((
m_rgba) & 0xFF0000) >> 16);
314 return (((
m_rgba) & 0x00FF00) >> 8);
319 return ((
m_rgba) & 0x0000FF);
324 return (((
m_rgba) & 0xFF000000) >> 24);
330 *a = (
m_rgba & 0xFF000000) >> 24;
331 *r = (
m_rgba & 0xFF0000) >> 16;
332 *g = (
m_rgba & 0xFF00) >> 8;
343 assert((hexColor.size() >= 7) && (hexColor.size() <= 9));
344 assert(hexColor[0] ==
'#');
349 if (hexColor.size() == 9)
353 a = int((highA << 4) + lowA);
358 int r = int((highR << 4) + lowR);
362 int g = int((highG << 4) + lowG);
366 int b = int((highB << 4) + lowB);
377 std::string result(buffer);
384 std::string result(buffer);
391 m_rgba = (a << 24) + (r << 16) + (g << 8) + b;
402 #endif // __TERRALIB_COLOR_INTERNAL_RGBACOLOR_H unsigned char GetDecimalFromHexNotCS(unsigned char hexValue)
It returns the decimal value in a char from a given hex value (for example: 'A' => 10...
void setColor(const std::string &hexColor)
It sets the color using a two hexadecimal RGB-encoded color.
int getRed() const
It returns the red component color value (a value from 0 to 255).
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Configuration flags for the Color module of TerraLib.
enum value, format #RRGGBB
RGBAColor()
Default constructor of a new color.
enum value, format #AARRGGBB
te::color::RGBAColor & operator=(const RGBAColor &color)
Assigns a copy of a color to this color, and returns a reference to it.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
NameFormat
NameFormat enum.
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
bool operator!=(const RGBAColor &color) const
It compares the colors are different.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
int getRgba() const
It returns the color value (0xAARRGGBB).
bool operator==(const RGBAColor &color) const
It compares the colors are iqual.
int m_rgba
It returns the internal representation as a 32-bits RGBA color.
std::string getColor(const NameFormat format=HexRgb) const
It gets the color encoded using two hexadecimal digits per primary-color component, in the order Red, Green, Blue, if HexRgb format, or Alpha, Red, Green, Blue, if HexArgb format, prefixed with a hash (#) sign.