90 return ((
r == right
.r) && (
g == right
.b) && (
b == right
.b));
97 return ((
r != right
.r) || (
g != right
.b) || (
b != right
.b));
107 float redF = (
float)
r / 255.0f;
108 float greenF = (
float)
g / 255.0f;
109 float blueF = (
float)
b / 255.0f;
114 hue = (
float)acos ((0.5 * ((redF - greenF) + (redF - blueF))) / sqrt ((pow ((redF - greenF), 2) + (redF - blueF) * (greenF - blueF))));
121 hue = (
float)(2.0f * 3.1415926535897932384626433832795 - acos ((0.5 * ((redF - greenF) + (redF - blueF)))) / sqrt ((pow ((redF - greenF), 2) + (redF - blueF) * (greenF - blueF))));
125 sat = 1 - 3 * min (min (redF, greenF), blueF) / (redF + greenF + blueF);
128 intensity = (redF + greenF + blueF) / 3;
139 if (intensity == 0.0f)
150 float domainOffset = 0.0f;
151 float red = 0.0, green = 0.0, blue = 0.0;
152 if (hue < (1.0f / 6.0f))
160 blue = intensity * (1.0f - sat);
161 green = blue + (intensity - blue) * domainOffset * 6.0f;
164 else if (hue < (2.0f / 6.0f))
172 domainOffset = hue - 1.0f / 6.0f;
174 blue = intensity * (1.0f - sat);
175 red = green - (intensity - blue) * domainOffset * 6.0f;
178 else if (hue < (3.0f / 6.0f))
184 domainOffset = hue - (2.0f / 6.0f);
186 red = intensity * (1.0f - sat);
187 blue = red - (intensity - red) * domainOffset * 6.0f;
190 else if (hue < (4.0f / 6.0f))
197 domainOffset = hue - (3.0f / 6.0f);
199 red = intensity * (1.0f - sat);
200 green = blue - (intensity - red) * domainOffset * 6.0f;
203 else if (hue < (5.0f / 6.0f))
210 domainOffset = hue - (4.0f / 6.0f);
212 green = intensity * (1.0f - sat);
213 red = green + (intensity - green) * domainOffset * 6.0f;
223 domainOffset = hue - (5.0f / 6.0f);
225 green = intensity * (1.0f - sat);
226 blue = red - (intensity - green) * domainOffset * 6.0f;
230 (
uchar)(0.5f + green * 255.0f)
, 231 (
uchar)(0.5f + blue * 255.0f)
PixelValue(const PixelValue &pixelValue)
static PixelValue Magenta
PixelValue & operator=(const PixelValue &right)
KKStr operator+(const char *right) const
void ToHSI(float &hue, float &sat, float &intensity) const
Computes the equivalent HSI values; RGB -> HSI.
PixelValue()
Constructs a 'PixelValue' instance from the the three provided values.
KKStr operator+(const char *left, const KKStr &right)
PixelValue(uchar _r, uchar _g, uchar _b)
Constructs a 'PixelValue' instance using the provided values for the color components.
bool operator!=(const PixelValue &right) const
unsigned char uchar
Unsigned character.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
KKStr StrFormatInt(kkint32 val, const char *mask)
PixelValue operator*(double fact) const
KKStr operator+(const KKStr &right) const
KKStr ToStr() const
Creates a displayable string reflecting the values of the three RGB components.
static PixelValue FromHSI(float hue, float sat, float intensity)
Will create an instance of PixelValue from the HSI values provided (HSI -> RGB).
static PixelValue FireBrick
bool operator==(const PixelValue &right) const
Used by the Raster Class to represent the contents of one pixel.