Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

plpixel32.h

Go to the documentation of this file.
00001 /*
00002 /--------------------------------------------------------------------
00003 |
00004 |      $Id: plpixel32.h,v 1.1 2004/05/21 21:02:53 maxx Exp $
00005 |
00006 |      Copyright (c) 1996-1998 Ulrich von Zadow
00007 |
00008 \--------------------------------------------------------------------
00009 */
00010 
00011 #ifndef INCL_PLPIXEL32
00012 #define INCL_PLPIXEL32
00013 
00014 #include "plpixeldefs.h"
00015 #include "plpaintlibdefs.h"
00016 
00021 class PLPixel32
00022 {
00023   public:
00025     PLPixel32 ();
00027     PLPixel32 (PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a);
00029     PLPixel32 (PLBYTE r, PLBYTE g, PLBYTE b);
00031     void Set (PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a);
00033     void Set (PLBYTE r, PLBYTE g, PLBYTE b);
00035     void SetR (PLBYTE r);
00037     void SetG (PLBYTE g);
00039     void SetB (PLBYTE b);
00041     void SetA (PLBYTE a);
00043     PLBYTE GetR () const;
00045     PLBYTE GetG () const;
00047     PLBYTE GetB () const;
00049     PLBYTE GetA () const;
00050 
00052     bool operator ==(const PLPixel32 Pix) const;
00053 
00055     bool operator !=(const PLPixel32 Pix) const;
00056 
00060     int BoxDist (const PLPixel32 Pix) const;
00061 
00065     static PLPixel32 Blend (int Factor, const PLPixel32 Pix1, 
00066                             const PLPixel32 Pix2);
00067 
00068   private:
00069     PLBYTE m_Data[4];
00070 };
00071 
00072 inline PLPixel32::PLPixel32()
00073 {
00074 }
00075 
00076 
00077 inline PLPixel32::PLPixel32(PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a)
00078 {
00079   Set (r, g, b, a);
00080 }
00081 
00082 
00083 inline PLPixel32::PLPixel32(PLBYTE r, PLBYTE g, PLBYTE b)
00084 {
00085   Set (r, g, b, 255);
00086 }
00087 
00088 
00089 inline void PLPixel32::Set(PLBYTE r, PLBYTE g, PLBYTE b, PLBYTE a)
00090 {
00091   m_Data[PL_RGBA_RED] = r;
00092   m_Data[PL_RGBA_GREEN] = g;
00093   m_Data[PL_RGBA_BLUE] = b;
00094   m_Data[PL_RGBA_ALPHA] = a;
00095 }
00096 
00098 inline void PLPixel32::Set (PLBYTE r, PLBYTE g, PLBYTE b)
00099 {
00100   m_Data[PL_RGBA_RED] = r;
00101   m_Data[PL_RGBA_GREEN] = g;
00102   m_Data[PL_RGBA_BLUE] = b;
00103 }
00104 
00105 inline void PLPixel32::SetR(PLBYTE r)
00106 {
00107   m_Data[PL_RGBA_RED] = r;
00108 }
00109 
00110 
00111 inline void PLPixel32::SetG(PLBYTE g)
00112 {
00113   m_Data[PL_RGBA_GREEN] = g;
00114 }
00115 
00116 
00117 inline void PLPixel32::SetB(PLBYTE b)
00118 {
00119   m_Data[PL_RGBA_BLUE] = b;
00120 }
00121 
00122 
00123 inline void PLPixel32::SetA(PLBYTE a)
00124 {
00125   m_Data[PL_RGBA_ALPHA] = a;
00126 }
00127 
00128 
00129 inline PLBYTE PLPixel32::GetR() const
00130 {
00131   return m_Data[PL_RGBA_RED];
00132 }
00133 
00134 
00135 inline PLBYTE PLPixel32::GetG() const
00136 {
00137   return m_Data[PL_RGBA_GREEN];
00138 }
00139 
00140 
00141 inline PLBYTE PLPixel32::GetB() const
00142 {
00143   return m_Data[PL_RGBA_BLUE];
00144 }
00145 
00146 
00147 inline PLBYTE PLPixel32::GetA() const
00148 {
00149   return m_Data[PL_RGBA_ALPHA];
00150 }
00151 
00152 inline int PLPixel32::BoxDist (const PLPixel32 Pix) const
00153 {
00154   return (abs ((int)GetR()-Pix.GetR()) +
00155           abs ((int)GetG()-Pix.GetG()) +
00156           abs ((int)GetB()-Pix.GetB()));
00157 }
00158 
00159 inline PLPixel32 PLPixel32::Blend (int Factor, const PLPixel32 Pix1, const PLPixel32 Pix2)
00160 {
00161   PLASSERT (Factor >= 0 && Factor <= 256);
00162 
00163   return PLPixel32 ((Pix1.GetR()*Factor+Pix2.GetR()*(256-Factor))>>8,
00164                     (Pix1.GetG()*Factor+Pix2.GetG()*(256-Factor))>>8,
00165                     (Pix1.GetB()*Factor+Pix2.GetB()*(256-Factor))>>8,
00166                     Pix1.GetA());
00167 }
00168 
00169 inline bool PLPixel32::operator ==(const PLPixel32 Pix) const
00170 {
00171   return (*(const PLLONG *)this == *(const PLLONG*)&Pix);
00172 }
00173 
00174 inline bool PLPixel32::operator !=(const PLPixel32 Pix) const
00175 {
00176   return (!(*this == Pix));
00177 }
00178 
00179 
00180 #endif
00181 
00182 /*
00183 /--------------------------------------------------------------------
00184 |
00185 |      $Log: plpixel32.h,v $
00186 |      Revision 1.1  2004/05/21 21:02:53  maxx
00187 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00188 |
00189 |      Revision 1.1  2002/11/13 01:58:22  mspindle
00190 |      *** empty log message ***
00191 |
00192 |      Revision 1.5  2001/10/21 17:12:40  uzadow
00193 |      Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel.
00194 |
00195 |      Revision 1.4  2001/10/06 22:03:26  uzadow
00196 |      Added PL prefix to basic data types.
00197 |
00198 |      Revision 1.3  2001/09/28 19:50:56  uzadow
00199 |      Added some 24 bpp stuff & other minor features.
00200 |
00201 |      Revision 1.2  2001/09/24 14:13:18  uzadow
00202 |      Added Blend, improved const-correctness.
00203 |
00204 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00205 |      Added global name prefix PL, changed most filenames.
00206 |
00207 |      Revision 1.3  2001/09/15 14:30:20  uzadow
00208 |      Fixed PLPixel32 initialization bug.
00209 |
00210 |      Revision 1.2  2001/09/13 20:45:35  uzadow
00211 |      Added 8-bpp pixel class.
00212 |
00213 |      Revision 1.1  2000/12/18 22:42:52  uzadow
00214 |      Replaced RGBAPIXEL with PLPixel32.
00215 |
00216 |
00217 \--------------------------------------------------------------------
00218 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1