KSquare Utilities
PixelValue.h
Go to the documentation of this file.
1 /* PixelValue.h -- Class that represents one pixel; works in conjunction with the Raster class.
2  * Copyright (C) 1994-2014 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 
6 #ifndef _PIXELVALUE_
7 #define _PIXELVALUE_
8 
9 #include "KKBaseTypes.h"
10 #include "KKStr.h"
11 
12 
13 namespace KKB
14 {
15  /**
16  *@class PixelValue PixelValue.h
17  *@brief Used by the Raster Class to represent the contents of one pixel.
18  *@details There are several predefined colors to pick from or you can
19  * work with the individual color channels separately.
20  *@see Raster
21  */
22  class PixelValue
23  {
24  public:
25 
26  /** @brief Constructs a 'PixelValue' instance from the the three provided values. */
27  PixelValue ();
28 
29  /** @brief Constructs a 'PixelValue' instance using the provided values for the color components. */
30  PixelValue (uchar _r, uchar _g, uchar _b);
31 
32  PixelValue (const PixelValue& pixelValue);
33 
34  static PixelValue Aqua;
35  static PixelValue Black;
36  static PixelValue Blue;
37  static PixelValue Brown;
38  static PixelValue Cyan;
40  static PixelValue Green;
44  static PixelValue Pink;
46  static PixelValue Red;
47  static PixelValue Teal;
49  static PixelValue White;
51 
55 
56  /**
57  *@brief Will create an instance of PixelValue from the HSI values provided (HSI -> RGB).
58  *@details Used "http://www.codeguru.com/forum/archive/index.php/t-134892.html" for inspiration.
59  *@param[in] hue Angle between 0 and (2 x Pi).
60  *@param[in] sat Saturation of color, a number between 0.0 and 1.0.
61  *@param[in] intensity Intensity.
62  */
63  static
64  PixelValue FromHSI (float hue,
65  float sat,
66  float intensity
67  );
68 
69  /**
70  *@brief Computes the equivalent HSI values; RGB -> HSI.
71  *@details Used "http://www.codeguru.com/forum/archive/index.php/t-134892.html" for inspiration.
72  *@param[out] hue Angle in radians.
73  *@param[out] sat Saturation between 0.0 and 1.0.
74  *@param[out] intensity Intensity between 0.0 and 1.0.
75  */
76  void ToHSI (float& hue,
77  float& sat,
78  float& intensity
79  ) const;
80 
81  /** @brief Creates a displayable string reflecting the values of the three RGB components. */
82  KKStr ToStr () const;
83 
84  PixelValue& operator= (const PixelValue& right);
85 
86  PixelValue operator* (double fact) const;
87 
88  bool operator== (const PixelValue& right) const;
89  bool operator!= (const PixelValue& right) const;
90  };
91 } /* KKB */
92 
93 #endif
PixelValue(const PixelValue &pixelValue)
Definition: PixelValue.cpp:52
static PixelValue Magenta
Definition: PixelValue.h:42
PixelValue & operator=(const PixelValue &right)
Definition: PixelValue.cpp:66
void ToHSI(float &hue, float &sat, float &intensity) const
Computes the equivalent HSI values; RGB -> HSI.
Definition: PixelValue.cpp:102
static PixelValue Blue
Definition: PixelValue.h:36
static PixelValue Orange
Definition: PixelValue.h:43
PixelValue()
Constructs a 'PixelValue' instance from the the three provided values.
Definition: PixelValue.cpp:44
KKTHread * KKTHreadPtr
static PixelValue Teal
Definition: PixelValue.h:47
static PixelValue Aqua
Definition: PixelValue.h:34
static PixelValue Black
Definition: PixelValue.h:35
PixelValue(uchar _r, uchar _g, uchar _b)
Constructs a 'PixelValue' instance using the provided values for the color components.
Definition: PixelValue.cpp:60
bool operator!=(const PixelValue &right) const
Definition: PixelValue.cpp:95
static PixelValue Brown
Definition: PixelValue.h:37
static PixelValue Pink
Definition: PixelValue.h:44
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
static PixelValue Indigo
Definition: PixelValue.h:41
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
static PixelValue White
Definition: PixelValue.h:49
static PixelValue Yellow
Definition: PixelValue.h:50
static PixelValue Purple
Definition: PixelValue.h:45
PixelValue operator*(double fact) const
Definition: PixelValue.cpp:78
static PixelValue Red
Definition: PixelValue.h:46
KKStr ToStr() const
Creates a displayable string reflecting the values of the three RGB components.
Definition: PixelValue.cpp:237
static PixelValue FromHSI(float hue, float sat, float intensity)
Will create an instance of PixelValue from the HSI values provided (HSI -> RGB).
Definition: PixelValue.cpp:133
static PixelValue Violet
Definition: PixelValue.h:48
static PixelValue FireBrick
Definition: PixelValue.h:39
static PixelValue Green
Definition: PixelValue.h:40
bool operator==(const PixelValue &right) const
Definition: PixelValue.cpp:88
Used by the Raster Class to represent the contents of one pixel.
Definition: PixelValue.h:22
static PixelValue Cyan
Definition: PixelValue.h:38