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

PixelRGB24.h

Go to the documentation of this file.
00001 
00023 #ifndef PIXEL_RGB24_H
00024 #define PIXEL_RGB24_H
00025 class PixelRGB24;
00026 //#include "PixelRGB32.h"
00027 #include <iostream>
00028 
00029 using namespace std;
00030 
00031 class PixelRGB24
00039 {
00052         friend ostream& operator << (ostream& os, PixelRGB24& p)
00053         {
00054                 os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
00055                 return os;
00056         }
00057 
00058 protected:
00059         unsigned char pixel[3]; 
00060 
00061 
00062 public:
00068         PixelRGB24()
00069          { pixel[0] = pixel[1] = pixel[2] = 0; }
00070 
00071 
00078         PixelRGB24(unsigned char red, unsigned char green, unsigned char blue)
00079         {
00080                 pixel[0] = red;
00081                 pixel[1] = green;
00082                 pixel[2] = blue;
00083         }
00084 
00085 
00096         PixelRGB24& operator = (PixelRGB24& 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         unsigned char& operator [] (int i)
00117         {
00118                 return pixel[i];
00119         }
00120 
00131         const unsigned char& operator [] (int i) const
00132         {
00133                 return pixel[i];
00134         }
00135 
00143         operator unsigned char* ()
00144         {
00145                 return (unsigned char*) pixel;
00146         }
00147 
00159         bool operator == (PixelRGB24& p)
00160         {
00161                 return (   pixel[0] == p.pixel[0]
00162                         && pixel[1] == p.pixel[1]
00163                         && pixel[2] == p.pixel[2]);
00164         }
00165 
00166 
00179         bool operator != (PixelRGB24& p)
00180         {
00181                 return (   pixel[0] != p.pixel[0]
00182                         || pixel[1] != p.pixel[1]
00183                         || pixel[2] != p.pixel[2]);
00184         }
00185 
00197         PixelRGB24& operator += (PixelRGB24& p)
00198         {
00199                 pixel[0] += p[0];
00200                 pixel[1] += p[1];
00201                 pixel[2] += p[2];
00202 
00203                 return *this;
00204         }
00205 
00216         PixelRGB24& operator -= (PixelRGB24& p)
00217         {
00218                 pixel[0] -= p[0];
00219                 pixel[1] -= p[1];
00220                 pixel[2] -= p[2];
00221 
00222                 return *this;
00223         }
00224 
00234         PixelRGB24& operator *= (double k)
00235         {
00236                 pixel[0] = (int) (k*(double)pixel[0]);
00237                 pixel[1] = (int) (k*(double)pixel[1]);
00238                 pixel[2] = (int) (k*(double)pixel[2]);
00239 
00240                 return *this;
00241         }
00242 
00243         PixelRGB24& operator *= (PixelRGB24& p)
00244         {
00245                 pixel[0] *= p[0];
00246                 pixel[1] *= p[1];
00247                 pixel[2] *= p[2];
00248 
00249                 return *this;
00250         }
00251 
00252         PixelRGB24& operator /= (PixelRGB24& p)
00253         {
00254                 pixel[0] /= p[0];
00255                 pixel[1] /= p[1];
00256                 pixel[2] /= p[2];
00257 
00258                 return *this;
00259         }
00260 
00261 };
00262 
00263 
00264 #endif  // PIXEL_RGB24_H

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