00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 #ifndef WAVEPACKET_COLOR_H__
00035 #define WAVEPACKET_COLOR_H__
00036 
00037 
00038 #include "common/common.h"
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 struct img_color_t {
00054         
00055         enum eConstants {
00056                 eMaxComponent   = 255   
00057         };
00058 
00059         
00060         img_color_t(void) throw() { }
00061 
00062         img_color_t(IN int r, IN int g, IN int b, IN int a = eMaxComponent) throw()
00063                 { this->set(r, g, b, a); }
00064         img_color_t(IN const img_color_t& c) throw() { *this = c; }
00065 
00066         
00067         const img_color_t& operator=(IN const img_color_t& c) throw() {
00068                         red = c.red;
00069                         green = c.green;
00070                         blue = c.blue;
00071                         alpha = c.alpha;
00072                         return *this;
00073                 }
00074 
00075 
00076 
00077         void set(IN int r, IN int g, IN int b, IN int a = eMaxComponent) throw() {
00078                         ASSERT(0 <= r && r <= eMaxComponent, "bad red: %d", r);
00079                         ASSERT(0 <= g && g <= eMaxComponent, "bad green: %d", g);
00080                         ASSERT(0 <= b && b <= eMaxComponent, "bad blue: %d", b);
00081                         ASSERT(0 <= a && a <= eMaxComponent, "bad alpha: %d", a);
00082                         red = r;
00083                         green = g;
00084                         blue = b;
00085                         alpha = a;
00086                 }
00087 
00088 
00089         void clear(void) throw() {
00090                         red = green = blue = 0;
00091                         alpha = eMaxComponent;
00092                 }
00093 
00094 
00095         void dump(IN const char * title) const throw() {
00096                         DPRINTF("%s: r=%d, g=%d, b=%d, a=%d",
00097                             title, red, green, blue, alpha);
00098                 }
00099 
00100         
00101         byte_t          red;
00102         byte_t          green;
00103         byte_t          blue;
00104         byte_t          alpha;
00105 };
00106 
00107 
00108 
00109 
00110 struct glut_color_t {
00111         
00112         glut_color_t(void) throw() { }
00113 
00114 
00115         glut_color_t(IN float r, IN float g, IN float b, IN float a = 1.0) throw()
00116                 { this->set(r, g, b, a); }
00117         glut_color_t(IN const glut_color_t& c) throw() { *this = c; }
00118 
00119         
00120         const glut_color_t& operator=(IN const glut_color_t& c) throw() {
00121                         red = c.red;
00122                         green = c.green;
00123                         blue = c.blue;
00124                         alpha = c.alpha;
00125                         return *this;
00126                 }
00127 
00128 
00129 
00130         void set(IN float r, IN float g, IN float b, IN float a = 1.0) throw() {
00131                         ASSERT(0 <= r && r <= 1.0, "Bad red: %f", r);
00132                         ASSERT(0 <= g && g <= 1.0, "Bad green: %f", g);
00133                         ASSERT(0 <= b && b <= 1.0, "Bad blue: %f", b);
00134                         ASSERT(0 <= a && a <= 1.0, "Bad alpha: %f", a);
00135                         red = r;
00136                         green = g;
00137                         blue = b;
00138                         alpha = a;
00139                 }
00140 
00141 
00142         void clear(void) throw() {
00143                         red = green = blue = 0;
00144                         alpha = 1.0;
00145                 }
00146 
00147 
00148         void dump(IN const char * title) const throw() {
00149                         DPRINTF("%s: r=%5.3f, g=%5.3f, b=%5.3f, a=%5.3f",
00150                             title, red, green, blue, alpha);
00151                 }
00152 
00153         
00154         float   red;
00155         float   green;
00156         float   blue;
00157         float   alpha;
00158 };
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 void getImgColorFromString(IN const char * text,
00169                         OUT img_color_t& color);
00170 
00171 
00172 
00173 #endif  // WAVEPACKET_COLOR_H__
00174