Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ColorScale.h

Go to the documentation of this file.
00001 
00005 struct Color
00006 
00007 {
00008   real r, g, b;   
00009 
00010   Color ()                                        { r=g=b=0; }
00011 
00012   Color (real c)                                  { r=g=b=c; }
00013   Color (real rr, double gg, double bb)           { r=rr; g=gg; b=bb; }
00014   Color (const Color& c)                          { r=c.r; g=c.g; b=c.b; }
00015 
00016   void operator = (const Color& c)                { r=c.r; g=c.g; b=c.b; }
00017 
00018   void setColor (const Color& c)                  { r=c.r; g=c.g; b=c.b; }
00019   void setColor (real rr, real gg, real bb)       { r=rr; g=gg; b=bb; }
00020   void setColor (real c)                          { r=g=b=c; }
00021 
00022   void print (Os out) {
00023     out->getFormat()==BINARY?out<<r<<g<<b:out<<r<<nl<<g<<nl<<b<<nl; }
00024   void scan  (Is in )                              { in >> r >> b >> g; }
00025 
00026   bool isBlack()         { return getbool(r==0 && g==0 && b==0); }
00027   bool isGray()          { return getbool(r==g && g==b && b==r); }
00028 };
00029 
00030 
00099 struct ColorScale
00100 
00101 {
00102   Color low;
00103   Color high;
00104 
00105   real min_value;
00106   real max_value;
00107 
00108 
00109   void rgb2ihs
00110      (
00111       const real& r,
00112       const real& g,
00113       const real& b,
00114             real& i,
00115             real& h,
00116             real& s
00117      );
00118 
00119   void ihs2rgb
00120      (
00121       const real& i,
00122       const real& h,
00123       const real& s,
00124             real& r,
00125             real& g,
00126             real& b
00127      );
00128 
00129   Color ihs_interpolation
00130      (
00131       const real& value
00132      );
00133 
00134 
00135 
00136   void rgb2cie
00137      (
00138       const real& r,
00139                const real& g,
00140                const real& b,
00141                      real& x,
00142                      real& y,
00143                      real& z
00144      );
00145 
00146   void cie2rgb
00147      (
00148       const real& l,
00149       const real& u,
00150       const real& v,
00151             real& x,
00152             real& y,
00153             real& z
00154      );
00155 
00156   Color cie_interpolation
00157      (
00158       const real& value
00159      );
00160 
00161 
00162 
00163   void rgb2luv
00164      (
00165       const real& r,
00166       const real& g,
00167       const real& b,
00168             real& l,
00169             real& u,
00170             real& v
00171      );
00172 
00173   void luv2rgb
00174      (
00175       const real& l,
00176       const real& u,
00177       const real& v,
00178             real& r,
00179             real& g,
00180             real& b
00181      );
00182 
00183   Color luv_interpolation
00184      (
00185       const real& value
00186      );
00187 
00188 
00189 
00190   
00191   Color getColor
00192      (
00193       const real& value,
00194       const char* colorspace = "CIE" 
00195      );
00196 };
00197 
00198 

Copyright © 2003 inuTech GmbH. All rights reserved.