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

CPixel

Go to the documentation of this file.
00001 
00002 //The Pixel Class
00003 //
00004 //The purpose of this class is to house 3d colors.  If you wish to use color, you must 
00005 //
00006 //instantiate an image using a class such as this one
00007 //
00009 #ifndef CPIXEL_CLASS
00010 #define CPIXEL_CLASS
00011 
00013 
00019 template<typename T>
00020 struct CPixel
00021 {
00022         inline CPixel():x(0),y(0),z(0){;};
00023         inline CPixel(int val):x(val),y(val),z(val){;}; //This is for type conversion as well
00024         inline CPixel(T X, T Y, T Z):x(X),y(Y),z(Z){;};
00025         T x,y,z; //The values where data is stored.
00026         inline CPixel<T> & operator=(CPixel<T> & RHS){x=RHS.x; y=RHS.y; z=RHS.z; return *this;};
00027         inline CPixel<T> & operator=(const T & RHS){x=RHS/3.0; y=RHS/3.0; z=RHS/3.0; return *this;};
00028         inline CPixel<T> & operator+=(CPixel<T> & RHS){x+=RHS.x;y+=RHS.y; z+=RHS.z;};
00029         inline CPixel<T> & operator-=(CPixel<T> & RHS){x-=RHS.x;y-=RHS.y; z-=RHS.z;};
00030         inline CPixel<T> & operator*=(CPixel<T> & RHS){x*=RHS.x;y*=RHS.y; z*=RHS.z;};
00031         inline CPixel<T> & operator/=(CPixel<T> & RHS){x/=RHS.x;y/=RHS.y; z/=RHS.z;};
00032         inline const double             intensity(){return (x+y+z)/3.0;};
00033         inline const CPixel<T>          operator+(T scalar){return CPixel(x+scalar,y+scalar,z+scalar);};
00034         inline const CPixel<T>          operator*(T scalar){return CPixel(x*scalar,y*scalar,z*scalar);};
00035         inline const CPixel<T>          operator-(T scalar){return CPixel(x-scalar,y-scalar,z-scalar);};
00036         inline const CPixel<T>          operator/(T scalar){return CPixel(x/scalar,y/scalar,z/scalar);};
00037         inline const CPixel operator+(CPixel<T> RHS){return CPixel(x+RHS.x,y+RHS.y,z+RHS.z);};
00038         inline const CPixel operator*(CPixel<T> RHS){return CPixel(x*RHS.x,y*RHS.y,z*RHS.z);};
00039         inline const CPixel operator-(CPixel<T> RHS){return CPixel(x-RHS.x,y-RHS.y,z-RHS.z);};
00040         inline const CPixel operator/(CPixel<T> RHS){return CPixel(x/RHS.x,y/RHS.y,z/RHS.z);};
00041 //This might be a buggy thing to include.  
00042 //This means that all the operators above will work with a RHS that is one of these types.
00043         operator CPixel<double>();
00044         operator CPixel<int>();
00045         operator CPixel<long>();
00046         operator CPixel<char>();
00047         operator CPixel<unsigned char>();
00048         operator CPixel<unsigned int>();
00049 };
00050 
00051 #endif //CPIXEL_CLASS

Generated at Thu Apr 25 20:30:41 2002 for SuperParr by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001