00001
00002
00003
00004
00005
00006
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
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218