2 * psychlops_g_color.h
\r
3 * Psychlops Standard Library (Universal)
\r
5 * Last Modified 2006/01/04 by Kenchi HOSOKAWA
\r
6 * (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
\r
9 #ifndef HEADER_PSYCHLOPS_GRAPHIC_COLOR
\r
10 #define HEADER_PSYCHLOPS_GRAPHIC_COLOR
\r
14 #include "psychlops_g_fundamental.h"
\r
16 namespace Psychlops {
\r
18 class ImageManipulator;
19 class DirectGetColor;
\r
21 friend class Canvas;
\r
23 friend class ImageManipulator;
24 friend class DirectGetColor;
\r
27 enum CALIBRATION_MODE { NOTHING=0, GAMMA_VALUE=1, TABLE=2, SOFTWARE_GAMMA_VALUE=101, SOFTWARE_TABLE=102,
\r
29 static bool strict_match;
\r
30 static void setGammaValue(double r, double g, double b);
\r
31 static void setGammaValue(double r, double g, double b, CALIBRATION_MODE mode);
\r
32 static void setGammaTable(const double * const table_r, const double * const table_g, const double * const table_b, const int num_steps);
\r
33 static void setGammaTable(const std::vector<double> &table_r, const std::vector<double> &table_g, const std::vector<double> &table_b);
\r
34 static void forceSoftwareCalibration(bool on_off = true);
\r
35 static CALIBRATION_MODE getCalibrationMode();
\r
38 double Red, Green, Blue, Alpha;
\r
40 static bool force_software_calibration_;
\r
41 static double gamma_r_inversed_, gamma_g_inversed_, gamma_b_inversed_;
\r
42 static double gamma_r_, gamma_g_, gamma_b_;
\r
43 static int table_size_;
\r
44 static std::vector<double> table_r_, table_g_, table_b_;
\r
45 static std::multimap<double, double> restore_table_r_, restore_table_g_, restore_table_b_;
\r
46 static void interpolateDiscreteSamplesInLinearFunction(const std::vector<double> &source, std::vector<double> &target);
\r
48 static void (*set_)(Color * col, double r, double g, double b, double a);
\r
49 static void set_direct(Color * col, double r, double g, double b, double a);
\r
50 static void set_correct_value(Color * col, double r, double g, double b, double a);
\r
51 static void set_correct_table(Color * col, double r, double g, double b, double a);
\r
52 static void set_correct_bits_mono(Color * col, double r, double g, double b, double a);
\r
54 static void (*get_)(const Color &col, double &r, double &g, double &b, double &a);
\r
55 static void get_direct(const Color &col, double &r, double &g, double &b, double &a);
\r
56 static void get_restore_gamma(const Color &col, double &r, double &g, double &b, double &a);
\r
57 static void get_restore_table(const Color &col, double &r, double &g, double &b, double &a);
\r
58 static void get_restore_bits_mono(const Color &col, double &r, double &g, double &b, double &a);
\r
60 static CALIBRATION_MODE calibration_mode_;
\r
61 static inline double Int8toFloat64(int value);
\r
62 static inline double limitvalue(double value);
\r
66 Color(double r, double g, double b, double a = 1.0);
\r
67 Color(double r, double g, double b, double a, bool dummy);
69 Color & set(double r, double g, double b, double a = 1.0);
70 Color & set(double r, double g, double b, double a, bool dummy);
71 Color & set(double gray);
\r
73 double getR() const;
\r
74 double getG() const;
\r
75 double getB() const;
\r
76 double getA() const;
\r
77 void get(double &r, double &g, double &b, double &a) const;
\r
81 bool operator ==(Color rhs);
\r
82 Color operator +(Color rhs);
\r
83 Color operator -(Color rhs);
\r
84 Color & operator +=(Color rhs);
\r
85 Color & operator -=(Color rhs);
\r
96 static Color magenta;
\r
99 static const Color null_color;
103 } /* <- namespace Psycholops */
\r