A class to transform RGBA color to HSV, HSL and CMYK. More...
#include <ColorTransform.h>
Public Types | |
| enum | Spec {  Invalid, Rgb, Hsv, Cmyk, Hsl }  | 
Public Member Functions | |
Initializer Methods  | |
Methods related to instantiation and destruction.  | |
| ColorTransform () | |
| Default constructor of a new color.  More... | |
| ColorTransform (const ColorTransform &colt) | |
| It initializes a new with the given color transform.  More... | |
| ColorTransform (const RGBAColor &color) | |
| It initializes a new color with the given RGBAColor.  More... | |
| ColorTransform (const int &rgba) | |
| It initializes a new color with the given rgba value.  More... | |
| ColorTransform (const int r, const int g, const int b, const int a=255) | |
| It initializes a new color.  More... | |
| ~ColorTransform () | |
| Destructor.  More... | |
| te::color::ColorTransform & | operator= (const ColorTransform &colt) | 
| Assigns a copy of a color transform and returns a reference to it.  More... | |
| void | setRgba (int r, int g, int b, int a) | 
| It sets the color.  More... | |
| void | setRgba (int rgba) | 
| It sets the color.  More... | |
| void | setColor (const RGBAColor &cor) | 
| It sets the color.  More... | |
| void | getRgba (int *r, int *g, int *b, int *a=0) const | 
| It gets the color value.  More... | |
| int | getRgba () const | 
| It returns the color value (0xAARRGGBB).  More... | |
| te::color::RGBAColor | getColor () const | 
| It returns the RGBA color.  More... | |
| int | getRed () const | 
| It returns the red component.  More... | |
| int | getGreen () const | 
| It returns the green component.  More... | |
| int | getBlue () const | 
| It returns the blue component.  More... | |
| int | getAlpha () const | 
| It returns the alpha component.  More... | |
| void | setRed (int red) | 
| It sets the red component.  More... | |
| void | setGreen (int green) | 
| It sets the green component.  More... | |
| void | setBlue (int blue) | 
| It sets the blue component.  More... | |
| void | setAlpha (int alpha) | 
| It sets the alpha component.  More... | |
| te::color::ColorTransform | toRgb () const | 
| It returns the color tranform in Rgb spec.  More... | |
| te::color::ColorTransform | toHsv () const | 
| It returns the color tranform in Hsv spec.  More... | |
| te::color::ColorTransform | toHsl () const | 
| It returns the color tranform in Hsl spec.  More... | |
| te::color::ColorTransform | toCmyk () const | 
| It returns the color tranform in Cmyk spec.  More... | |
| int | getHsvHue () const | 
| It returns the hue component of this color.  More... | |
| int | getHsvSaturation () const | 
| It returns the saturation component of this color.  More... | |
| int | getValue () const | 
| It returns the value component of this color.  More... | |
| void | getHsv (int *h, int *s, int *v, int *a=0) const | 
| It gets the h, s, v components of this color.  More... | |
| void | setHsv (int h, int s, int v, int a=255) | 
| It sets the h, s, v components of this color.  More... | |
| int | getCyan () const | 
| It gets the cyan component of this color.  More... | |
| int | getMagenta () const | 
| It gets the magenta component of this color.  More... | |
| int | getYellow () const | 
| It gets the yellow component of this color.  More... | |
| int | getBlack () const | 
| It gets the black component of this color.  More... | |
| void | getCmyk (int *c, int *m, int *y, int *k, int *a=0) | 
| It gets the c, m, y, k components of this color.  More... | |
| void | setCmyk (int c, int m, int y, int k, int a=255) | 
| It sets the c, m, y, k components of this color.  More... | |
| int | getHslHue () const | 
| It returns the hue component of this color.  More... | |
| int | getHslSaturation () const | 
| It returns the saturation component of this color.  More... | |
| int | getLightness () const | 
| It returns the lightness component of this color.  More... | |
| void | getHsl (int *h, int *s, int *l, int *a=0) const | 
| It gets the h, s, l components of this color.  More... | |
| void | setHsl (int h, int s, int l, int a=255) | 
| It sets the h, s, l components of this color.  More... | |
| bool | operator== (const ColorTransform &colt) const | 
| It compares the color tranforms are iqual.  More... | |
| bool | operator!= (const ColorTransform &colt) const | 
| It compares the color tranforms are different.  More... | |
Private Member Functions | |
| bool | fuzzyCompare (double p1, double p2) const | 
| It compares the double valuea are iqual.  More... | |
| bool | fuzzyIsNull (double d) const | 
| It verifies the double is null.  More... | |
| void | invalidate () | 
| Marks the color transform as invalid and sets all components to zero (alpha is set to fully opaque).  More... | |
| bool | isValid () const | 
| It checks if the color is valid.  More... | |
| int | round (double d) const | 
| It rounds the double value to int value.  More... | |
| template<typename T > | |
| const T & | vMin (const T &a, const T &b) const | 
Private Attributes | |
| union { | |
| struct { | |
| unsigned short alpha | |
| unsigned short black | |
| unsigned short cyan | |
| unsigned short magenta | |
| unsigned short yellow | |
| } acmyk | |
| struct { | |
| unsigned short alpha | |
| unsigned short hue | |
| unsigned short lightness | |
| unsigned short pad | |
| unsigned short saturation | |
| } ahsl | |
| struct { | |
| unsigned short alpha | |
| unsigned short hue | |
| unsigned short pad | |
| unsigned short saturation | |
| unsigned short value | |
| } ahsv | |
| struct { | |
| unsigned short alpha | |
| unsigned short blue | |
| unsigned short green | |
| unsigned short pad | |
| unsigned short red | |
| } argb | |
| unsigned short array [5] | |
| } | m_params | 
| Spec | m_spec | 
A class to transform RGBA color to HSV, HSL and CMYK.
Definition at line 50 of file ColorTransform.h.
| Enumerator | |
|---|---|
| Invalid | |
| Rgb | |
| Hsv | |
| Cmyk | |
| Hsl | |
Definition at line 54 of file ColorTransform.h.
| te::color::ColorTransform::ColorTransform | ( | ) | 
Default constructor of a new color.
Definition at line 29 of file ColorTransform.cpp.
References invalidate().
| te::color::ColorTransform::ColorTransform | ( | const ColorTransform & | colt | ) | 
It initializes a new with the given color transform.
| colt | The color transform. | 
Definition at line 34 of file ColorTransform.cpp.
| te::color::ColorTransform::ColorTransform | ( | const RGBAColor & | color | ) | 
It initializes a new color with the given RGBAColor.
| color | The RGBAColor. | 
Definition at line 40 of file ColorTransform.cpp.
References te::color::RGBAColor::getAlpha(), te::color::RGBAColor::getBlue(), te::color::RGBAColor::getGreen(), and te::color::RGBAColor::getRed().
| te::color::ColorTransform::ColorTransform | ( | const int & | rgba | ) | 
It initializes a new color with the given rgba value.
| rgba | The rgba value. | 
Definition at line 50 of file ColorTransform.cpp.
| te::color::ColorTransform::ColorTransform | ( | const int | r, | 
| const int | g, | ||
| const int | b, | ||
| const int | a = 255  | 
        ||
| ) | 
It initializes a new color.
| r | Red component (range from 0 to 255). | 
| g | Green component (range from 0 to 255). | 
| b | Blue component (range from 0 to 255). | 
| a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). | 
Definition at line 60 of file ColorTransform.cpp.
| te::color::ColorTransform::~ColorTransform | ( | ) | 
Destructor.
Definition at line 70 of file ColorTransform.cpp.
      
  | 
  inlineprivate | 
It compares the double valuea are iqual.
| p1 | First value. | 
| p2 | Second value. | 
Definition at line 524 of file ColorTransform.h.
References vMin().
      
  | 
  inlineprivate | 
It verifies the double is null.
| d | Value to be verified. | 
Definition at line 529 of file ColorTransform.h.
| int te::color::ColorTransform::getAlpha | ( | ) | const | 
It returns the alpha component.
Definition at line 162 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| int te::color::ColorTransform::getBlack | ( | ) | const | 
It gets the black component of this color.
Definition at line 584 of file ColorTransform.cpp.
| int te::color::ColorTransform::getBlue | ( | ) | const | 
It returns the blue component.
Definition at line 155 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| void te::color::ColorTransform::getCmyk | ( | int * | c, | 
| int * | m, | ||
| int * | y, | ||
| int * | k, | ||
| int * | a = 0  | 
        ||
| ) | 
It gets the c, m, y, k components of this color.
| c | The cyan component. | 
| m | The magenta component. | 
| y | The yellow component. | 
| k | The black component. | 
| a | The alpha component. | 
Definition at line 591 of file ColorTransform.cpp.
| te::color::RGBAColor te::color::ColorTransform::getColor | ( | ) | const | 
It returns the RGBA color.
Definition at line 135 of file ColorTransform.cpp.
| int te::color::ColorTransform::getCyan | ( | ) | const | 
It gets the cyan component of this color.
Definition at line 563 of file ColorTransform.cpp.
| int te::color::ColorTransform::getGreen | ( | ) | const | 
It returns the green component.
Definition at line 148 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| void te::color::ColorTransform::getHsl | ( | int * | h, | 
| int * | s, | ||
| int * | l, | ||
| int * | a = 0  | 
        ||
| ) | const | 
It gets the h, s, l components of this color.
| h | The cyan component. | 
| s | The magenta component. | 
| l | The yellow component. | 
| a | The alpha component. | 
Definition at line 652 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| int te::color::ColorTransform::getHslHue | ( | ) | const | 
It returns the hue component of this color.
Definition at line 631 of file ColorTransform.cpp.
| int te::color::ColorTransform::getHslSaturation | ( | ) | const | 
It returns the saturation component of this color.
Definition at line 638 of file ColorTransform.cpp.
| void te::color::ColorTransform::getHsv | ( | int * | h, | 
| int * | s, | ||
| int * | v, | ||
| int * | a = 0  | 
        ||
| ) | const | 
It gets the h, s, v components of this color.
| h | The hue component. | 
| s | The saturation component. | 
| v | The value component. | 
| a | The alpha component. | 
Definition at line 527 of file ColorTransform.cpp.
| int te::color::ColorTransform::getHsvHue | ( | ) | const | 
It returns the hue component of this color.
Definition at line 506 of file ColorTransform.cpp.
| int te::color::ColorTransform::getHsvSaturation | ( | ) | const | 
It returns the saturation component of this color.
Definition at line 513 of file ColorTransform.cpp.
| int te::color::ColorTransform::getLightness | ( | ) | const | 
It returns the lightness component of this color.
Definition at line 645 of file ColorTransform.cpp.
| int te::color::ColorTransform::getMagenta | ( | ) | const | 
It gets the magenta component of this color.
Definition at line 570 of file ColorTransform.cpp.
| int te::color::ColorTransform::getRed | ( | ) | const | 
It returns the red component.
Definition at line 141 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| void te::color::ColorTransform::getRgba | ( | int * | r, | 
| int * | g, | ||
| int * | b, | ||
| int * | a = 0  | 
        ||
| ) | const | 
It gets the color value.
| r | Red component. | 
| g | Green component. | 
| b | Blue component. | 
| a | Alpha component. | 
Definition at line 106 of file ColorTransform.cpp.
Referenced by te::se::GenerateRandomColor().
| int te::color::ColorTransform::getRgba | ( | ) | const | 
It returns the color value (0xAARRGGBB).
Definition at line 125 of file ColorTransform.cpp.
| int te::color::ColorTransform::getValue | ( | ) | const | 
It returns the value component of this color.
Definition at line 520 of file ColorTransform.cpp.
| int te::color::ColorTransform::getYellow | ( | ) | const | 
It gets the yellow component of this color.
Definition at line 577 of file ColorTransform.cpp.
      
  | 
  inlineprivate | 
Marks the color transform as invalid and sets all components to zero (alpha is set to fully opaque).
Definition at line 504 of file ColorTransform.h.
References Invalid, m_params, and m_spec.
Referenced by ColorTransform().
      
  | 
  inlineprivate | 
It checks if the color is valid.
Definition at line 514 of file ColorTransform.h.
| bool te::color::ColorTransform::operator!= | ( | const ColorTransform & | colt | ) | const | 
It compares the color tranforms are different.
| colt | The color transform to be compared. | 
Definition at line 715 of file ColorTransform.cpp.
References operator==().
| te::color::ColorTransform & te::color::ColorTransform::operator= | ( | const ColorTransform & | colt | ) | 
Assigns a copy of a color transform and returns a reference to it.
| color | The color transfom to be copied. | 
Definition at line 74 of file ColorTransform.cpp.
| bool te::color::ColorTransform::operator== | ( | const ColorTransform & | colt | ) | const | 
      
  | 
  inlineprivate | 
It rounds the double value to int value.
Definition at line 519 of file ColorTransform.h.
| void te::color::ColorTransform::setAlpha | ( | int | alpha | ) | 
It sets the alpha component.
Definition at line 191 of file ColorTransform.cpp.
| void te::color::ColorTransform::setBlue | ( | int | blue | ) | 
It sets the blue component.
Definition at line 183 of file ColorTransform.cpp.
| void te::color::ColorTransform::setCmyk | ( | int | c, | 
| int | m, | ||
| int | y, | ||
| int | k, | ||
| int | a = 255  | 
        ||
| ) | 
It sets the c, m, y, k components of this color.
| c | The cyan component. | 
| m | The magenta component. | 
| y | The yellow component. | 
| k | The black component. | 
| a | The alpha component. | 
Definition at line 611 of file ColorTransform.cpp.
| void te::color::ColorTransform::setColor | ( | const RGBAColor & | cor | ) | 
It sets the color.
| cor | The RGBA color. | 
Definition at line 101 of file ColorTransform.cpp.
References te::color::RGBAColor::getRgba().
| void te::color::ColorTransform::setGreen | ( | int | green | ) | 
It sets the green component.
Definition at line 175 of file ColorTransform.cpp.
| void te::color::ColorTransform::setHsl | ( | int | h, | 
| int | s, | ||
| int | l, | ||
| int | a = 255  | 
        ||
| ) | 
It sets the h, s, l components of this color.
| h | The cyan component. | 
| s | The magenta component. | 
| l | The yellow component. | 
| a | The alpha component. | 
Definition at line 671 of file ColorTransform.cpp.
Referenced by te::qt::widgets::colorbar::ColorBar::wheelEvent().
| void te::color::ColorTransform::setHsv | ( | int | h, | 
| int | s, | ||
| int | v, | ||
| int | a = 255  | 
        ||
| ) | 
It sets the h, s, v components of this color.
| h | The hue component. | 
| s | The saturation component. | 
| v | The value component. | 
| a | The alpha component. | 
Definition at line 546 of file ColorTransform.cpp.
Referenced by te::se::GenerateRandomColor().
| void te::color::ColorTransform::setRed | ( | int | red | ) | 
It sets the red component.
Definition at line 167 of file ColorTransform.cpp.
| void te::color::ColorTransform::setRgba | ( | int | r, | 
| int | g, | ||
| int | b, | ||
| int | a | ||
| ) | 
It sets the color.
| r | Red component (range from 0 to 255). | 
| g | Green component (range from 0 to 255). | 
| b | Blue component (range from 0 to 255). | 
| a | Alpha component. A range from 0 to 255 (see the macro TE_OPAQUE and TE_TRANSPARENT for the values of totally transparent and totally opaque). | 
Definition at line 82 of file ColorTransform.cpp.
| void te::color::ColorTransform::setRgba | ( | int | rgba | ) | 
It sets the color.
| rgba | The color represented by a number of 4 bytes, where the values ??are in the following order: alpha, red, green and blue. The alpha is the most significant byte. | 
Definition at line 92 of file ColorTransform.cpp.
| te::color::ColorTransform te::color::ColorTransform::toCmyk | ( | ) | const | 
| te::color::ColorTransform te::color::ColorTransform::toHsl | ( | ) | const | 
| te::color::ColorTransform te::color::ColorTransform::toHsv | ( | ) | const | 
| te::color::ColorTransform te::color::ColorTransform::toRgb | ( | ) | const | 
      
  | 
  inlineprivate | 
Definition at line 456 of file ColorTransform.h.
Referenced by fuzzyCompare().
| struct { ... } te::color::ColorTransform::acmyk | 
Referenced by toCmyk().
| struct { ... } te::color::ColorTransform::ahsl | 
Referenced by operator==(), and toHsl().
| struct { ... } te::color::ColorTransform::ahsv | 
Referenced by operator==(), and toHsv().
| unsigned short te::color::ColorTransform::alpha | 
Definition at line 466 of file ColorTransform.h.
| struct { ... } te::color::ColorTransform::argb | 
Referenced by operator==(), and toRgb().
| unsigned short te::color::ColorTransform::array[5] | 
Definition at line 500 of file ColorTransform.h.
Referenced by toRgb().
| unsigned short te::color::ColorTransform::black | 
Definition at line 488 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::blue | 
Definition at line 469 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::cyan | 
Definition at line 485 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::green | 
Definition at line 468 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::hue | 
Definition at line 476 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::lightness | 
Definition at line 496 of file ColorTransform.h.
| union { ... } te::color::ColorTransform::m_params | 
Referenced by ColorTransform(), invalidate(), operator=(), operator==(), toCmyk(), toHsl(), toHsv(), and toRgb().
      
  | 
  private | 
Definition at line 460 of file ColorTransform.h.
Referenced by ColorTransform(), invalidate(), isValid(), operator=(), operator==(), toCmyk(), toHsl(), toHsv(), and toRgb().
| unsigned short te::color::ColorTransform::magenta | 
Definition at line 486 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::pad | 
Definition at line 470 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::red | 
Definition at line 467 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::saturation | 
Definition at line 477 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::value | 
Definition at line 478 of file ColorTransform.h.
| unsigned short te::color::ColorTransform::yellow | 
Definition at line 487 of file ColorTransform.h.