Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

PixelRGB96.h

Go to the documentation of this file.
00001 
00023 #ifndef PIXEL_RGB96_H
00024 #define PIXEL_RGB96_H
00025 class PixelRGB96;
00026 #include "PixelRGB24.h"
00027 #include <iostream>
00028 
00029 using namespace std;
00030 
00031 class PixelRGB96
00039 {
00052         friend ostream& operator << (ostream& os, PixelRGB96& p)
00053         {
00054                 os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
00055                 return os;
00056         }
00057 
00058 protected:
00059         int pixel[3];   
00060 
00061 
00062 public:
00068         PixelRGB96()
00069          { pixel[0] = pixel[1] = pixel[2] = 0; }
00070 
00071 
00078         PixelRGB96(int red, int green, int blue)
00079         {
00080                 pixel[0] = red;
00081                 pixel[1] = green;
00082                 pixel[2] = blue;
00083         }
00084 
00085 
00096         PixelRGB96& operator = (PixelRGB96& p)
00097         {
00098                 pixel[0] = p[0];
00099                 pixel[1] = p[1];
00100                 pixel[2] = p[2];
00101 
00102                 return *this;
00103         }
00104 
00105 
00116         int& operator [] (int i)
00117         {
00118                 return pixel[i];
00119         }
00120 
00131         const int& operator [] (int i) const
00132         {
00133                 return pixel[i];
00134         }
00135 
00136 
00137 
00145         operator int* ()
00146         {
00147                 return (int*) pixel;
00148         }
00149 
00150 
00162         bool operator == (PixelRGB96& p)
00163         {
00164                 return (   pixel[0] == p.pixel[0]
00165                         && pixel[1] == p.pixel[1]
00166                         && pixel[2] == p.pixel[2]);
00167         }
00168 
00169 
00182         bool operator != (PixelRGB96& p)
00183         {
00184                 return (   pixel[0] != p.pixel[0]
00185                         || pixel[1] != p.pixel[1]
00186                         || pixel[2] != p.pixel[2]);
00187         }
00188 
00200         PixelRGB96& operator += (PixelRGB96& p)
00201         {
00202                 pixel[0] += p[0];
00203                 pixel[1] += p[1];
00204                 pixel[2] += p[2];
00205 
00206                 return *this;
00207         }
00208 
00219         PixelRGB96& operator -= (PixelRGB96& p)
00220         {
00221                 if((pixel[0] -= p[0]) < 0) pixel[0] = -pixel[0];
00222                 if((pixel[1] -= p[1]) < 1) pixel[1] = -pixel[1];
00223                 if((pixel[2] -= p[2]) < 2) pixel[2] = -pixel[2];
00224 
00225                 return *this;
00226         }
00227 
00237         PixelRGB96& operator *= (double k)
00238         {
00239                 pixel[0] = (int) (k*(double)pixel[0]);
00240                 pixel[1] = (int) (k*(double)pixel[1]);
00241                 pixel[2] = (int) (k*(double)pixel[2]);
00242 
00243                 return *this;
00244         }
00245 
00246         PixelRGB96& operator *= (PixelRGB96& p)
00247         {
00248                 pixel[0] *= p[0];
00249                 pixel[1] *= p[1];
00250                 pixel[2] *= p[2];
00251 
00252                 return *this;
00253         }
00254 
00255         PixelRGB96& operator /= (PixelRGB96& p)
00256         {
00257                 pixel[0] /= p[0];
00258                 pixel[1] /= p[1];
00259                 pixel[2] /= p[2];
00260 
00261                 return *this;
00262         }
00263 
00264 };
00265 
00266 
00267 #endif  // PIXEL_RGB96_H

Generated on Tue Jan 24 11:58:57 2006 for VETLib by  doxygen 1.4.4