|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef T_COLORVALUE_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define T_COLORVALUE_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixel.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TCOLOR_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TColorValue {
|
|
Shinya Kitaoka |
120a6e |
double m_r, m_g, m_b, m_m;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
TColorValue() : m_r(0), m_g(0), m_b(0), m_m(1){};
|
|
Shinya Kitaoka |
120a6e |
TColorValue(const TPixel32 &src) { setPixel(src); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getHsv(int &h, int &s, int &v) const;
|
|
Shinya Kitaoka |
120a6e |
void getHsv(int hsv[3]) const { getHsv(hsv[0], hsv[1], hsv[2]); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getHls(double hls[3]) const { getHls(hls[0], hls[1], hls[2]); }
|
|
Shinya Kitaoka |
120a6e |
void getHls(double &h, double &l, double &s) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setHsv(int h, int s, int v);
|
|
Shinya Kitaoka |
120a6e |
void setHsv(int hsv[3]) { setHsv(hsv[0], hsv[1], hsv[2]); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getRgb(int &r, int &g, int &b) const;
|
|
Shinya Kitaoka |
120a6e |
/*Sposto in tcolorvalue.cpp
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
r = (int)(m_r*255+0.5);
|
|
Shinya Kitaoka |
120a6e |
g = (int)(m_g*255+0.5);
|
|
Shinya Kitaoka |
120a6e |
b = (int)(m_b*255+0.5);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getRgb(int rgb[3]) const { getRgb(rgb[0], rgb[1], rgb[2]); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixel32 getPixel() const;
|
|
Shinya Kitaoka |
120a6e |
/*Sposto in tcolorvalue.cpp
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
int r,g,b; getRgb(r,g,b);
|
|
Shinya Kitaoka |
120a6e |
return TPixel32(r,g,b,(int)(m_m*255.0+0.5));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setRgb(int r, int g, int b);
|
|
Shinya Kitaoka |
120a6e |
/*Sposto in tcolorvalue.cpp
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
m_r = r/255.0;
|
|
Shinya Kitaoka |
120a6e |
m_g = g/255.0;
|
|
Shinya Kitaoka |
120a6e |
m_b = b/255.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setRgb(int rgb[3]) { setRgb(rgb[0], rgb[1], rgb[2]); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setPixel(const TPixel32 &src);
|
|
Shinya Kitaoka |
120a6e |
/*Sposto in tcolorvalue.cpp
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
setRgb(src.r, src.g,src.b);
|
|
Shinya Kitaoka |
120a6e |
m_m = src.m/255.0;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool operator==(const TColorValue &cv) const {
|
|
Shinya Kitaoka |
120a6e |
return cv.m_r == m_r && cv.m_g == m_g && cv.m_b == m_b && cv.m_m == m_m;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool operator!=(const TColorValue &cv) const { return !operator==(cv); }
|
|
Shinya Kitaoka |
120a6e |
bool operator<(const TColorValue &cv) const {
|
|
Shinya Kitaoka |
120a6e |
if (m_r < cv.m_r)
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
else if (m_r > cv.m_r)
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if (m_g < cv.m_g)
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
else if (m_g > cv.m_g)
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
if (m_b < cv.m_b)
|
|
Shinya Kitaoka |
120a6e |
return true;
|
|
Shinya Kitaoka |
120a6e |
else if (m_b > cv.m_b)
|
|
Shinya Kitaoka |
120a6e |
return false;
|
|
Shinya Kitaoka |
120a6e |
return (m_m < cv.m_m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
bool operator>=(const TColorValue &cv) const { return !(*this < cv); }
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>(const TColorValue &cv) const { return (cv < *this); }
|
|
Shinya Kitaoka |
120a6e |
bool operator<=(const TColorValue &cv) const { return (cv >= *this); }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|