Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

IMG_Color.h

00001 
00005 
00006 #ifndef _H_IMG_Color
00007 #define _H_IMG_Color
00008 
00009 class IMG_ColorRGBA;
00010 
00017 
00018 class IMG_ColorRGB {
00019 public:
00026         IMG_ColorRGB(float r=0, float g=0, float b=0)
00027                 : m_r(r), m_g(g), m_b(b) {}
00028 
00033         IMG_ColorRGB(const IMG_ColorRGB& c)
00034                 : m_r(c.m_r), m_g(c.m_g), m_b(c.m_b) {}
00035 
00040         inline IMG_ColorRGB(const IMG_ColorRGBA& c);
00041 
00043         float m_r;
00045         float m_g;
00047         float m_b;
00048 };
00049 
00050 
00057 
00058 class IMG_ColorRGBA {
00059 public:
00067         IMG_ColorRGBA(float r=0, float g=0, float b=0, float a=0)
00068                 : m_r(r), m_g(g), m_b(b), m_a(a) {}
00069 
00074         IMG_ColorRGBA(const IMG_ColorRGBA& c)
00075                 : m_r(c.m_r), m_g(c.m_g), m_b(c.m_b), m_a(c.m_a) {}
00076 
00081         IMG_ColorRGBA(const IMG_ColorRGB& c)
00082                 : m_r(c.m_r), m_g(c.m_g), m_b(c.m_b), m_a(0) {}
00083 
00090         inline void     blendColor(const IMG_ColorRGBA& c);
00091 
00093         float m_r;
00095         float m_g;
00097         float m_b;
00099         float m_a;
00100 };
00101 
00102 inline IMG_ColorRGB::IMG_ColorRGB(const IMG_ColorRGBA& c)
00103         : m_r(c.m_r), m_g(c.m_g), m_b(c.m_b) {}
00104 
00105 inline void     IMG_ColorRGBA::blendColor(const IMG_ColorRGBA& c)
00106 {
00107         float r1 = 1 - c.m_a; // The reverse of alpha
00108 #if IMG_REVERSED_ALPHA
00109         m_r = c.m_a * m_r + r1 * c.m_r;
00110         m_g = c.m_a * m_g + r1 * c.m_g;
00111         m_b = c.m_a * m_b + r1 * c.m_b;
00112 #else
00113         m_r = r1 * m_r + c.m_a * c.m_r;
00114         m_g = r1 * m_g + c.m_a * c.m_g;
00115         m_b = r1 * m_b + c.m_a * c.m_b;
00116 #endif
00117 }
00118 
00119 
00120 #endif // _H_IMG_Color

Generated at Thu May 3 17:29:38 2001 for ImgLib by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000