00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef INCL_PLPIXEL24
00012 #define INCL_PLPIXEL24
00013
00014 #include "plpixeldefs.h"
00015 #include "plpaintlibdefs.h"
00016 #include "plpixel32.h"
00017
00018
00019
00020
00021
00022 class PLPixel24
00023 {
00024 public:
00025
00026 PLPixel24 ();
00027
00028 PLPixel24 (PLBYTE r, PLBYTE g, PLBYTE b);
00029
00030 void Set (PLBYTE r, PLBYTE g, PLBYTE b);
00031
00032 void SetR (PLBYTE r);
00033
00034 void SetG (PLBYTE g);
00035
00036 void SetB (PLBYTE b);
00037
00038 PLBYTE GetR () const;
00039
00040 PLBYTE GetG () const;
00041
00042 PLBYTE GetB () const;
00043
00044
00045 PLPixel24 operator = (const PLPixel32 Pix);
00046
00047 operator PLPixel32 () const;
00048
00049
00050 bool operator ==(const PLPixel24&) const;
00051
00052
00053 bool operator !=(const PLPixel24&) const;
00054
00055
00056
00057
00058 int BoxDist (const PLPixel24 Pix) const;
00059
00060
00061
00062
00063 static PLPixel24 Blend (int Factor, const PLPixel24 Pix1,
00064 const PLPixel24 Pix2);
00065
00066 private:
00067 PLBYTE m_Data[3];
00068 };
00069
00070 inline PLPixel24::PLPixel24()
00071 {
00072 }
00073
00074
00075 inline PLPixel24::PLPixel24(PLBYTE r, PLBYTE g, PLBYTE b)
00076 {
00077 Set (r, g, b);
00078 }
00079
00080
00081 inline void PLPixel24::Set(PLBYTE r, PLBYTE g, PLBYTE b)
00082 {
00083 m_Data[PL_RGBA_RED] = r;
00084 m_Data[PL_RGBA_GREEN] = g;
00085 m_Data[PL_RGBA_BLUE] = b;
00086 }
00087
00088
00089 inline void PLPixel24::SetR(PLBYTE r)
00090 {
00091 m_Data[PL_RGBA_RED] = r;
00092 }
00093
00094
00095 inline void PLPixel24::SetG(PLBYTE g)
00096 {
00097 m_Data[PL_RGBA_GREEN] = g;
00098 }
00099
00100
00101 inline void PLPixel24::SetB(PLBYTE b)
00102 {
00103 m_Data[PL_RGBA_BLUE] = b;
00104 }
00105
00106
00107 inline PLBYTE PLPixel24::GetR() const
00108 {
00109 return m_Data[PL_RGBA_RED];
00110 }
00111
00112
00113 inline PLBYTE PLPixel24::GetG() const
00114 {
00115 return m_Data[PL_RGBA_GREEN];
00116 }
00117
00118
00119 inline PLBYTE PLPixel24::GetB() const
00120 {
00121 return m_Data[PL_RGBA_BLUE];
00122 }
00123
00124
00125 inline int PLPixel24::BoxDist (const PLPixel24 Pix) const
00126 {
00127 return (abs ((int)GetR()-Pix.GetR()) +
00128 abs ((int)GetG()-Pix.GetG()) +
00129 abs ((int)GetB()-Pix.GetB()));
00130 }
00131
00132
00133 inline PLPixel24 PLPixel24::Blend (int Factor, const PLPixel24 Pix1, const PLPixel24 Pix2)
00134 {
00135 PLASSERT (Factor >= 0 && Factor <= 256);
00136
00137 return PLPixel24 ((Pix1.GetR()*Factor+Pix2.GetR()*(256-Factor))>>8,
00138 (Pix1.GetG()*Factor+Pix2.GetG()*(256-Factor))>>8,
00139 (Pix1.GetB()*Factor+Pix2.GetB()*(256-Factor))>>8);
00140 }
00141
00142 inline PLPixel24 PLPixel24::operator = (const PLPixel32 Pix)
00143 {
00144 SetR (Pix.GetR());
00145 SetG (Pix.GetG());
00146 SetB (Pix.GetB());
00147
00148 return *this;
00149 }
00150
00151 inline PLPixel24::operator PLPixel32 () const
00152 {
00153 return PLPixel32 (GetR(), GetG(), GetB(), 255);
00154 }
00155
00156 inline bool PLPixel24::operator ==(const PLPixel24& Pix) const
00157 {
00158 return (GetR() == Pix.GetR() && GetG() == Pix.GetG() && GetB() == Pix.GetB());
00159 }
00160
00161 inline bool PLPixel24::operator !=(const PLPixel24& Pix) const
00162 {
00163 return (!(*this == Pix));
00164 }
00165
00166
00167 #endif
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188