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
00048 operator PLPixel32 () const;
00049
00050
00051 bool operator ==(const PLPixel24&) const;
00052
00053
00054 bool operator !=(const PLPixel24&) const;
00055
00056
00057
00058
00059 int BoxDist (const PLPixel24 Pix) const;
00060
00061
00062
00063
00064 static PLPixel24 Blend (int Factor, const PLPixel24 Pix1,
00065 const PLPixel24 Pix2);
00066
00067 private:
00068 PLBYTE m_Data[3];
00069 };
00070
00071 inline PLPixel24::PLPixel24()
00072 {
00073 }
00074
00075
00076 inline PLPixel24::PLPixel24(PLBYTE r, PLBYTE g, PLBYTE b)
00077 {
00078 Set (r, g, b);
00079 }
00080
00081
00082 inline void PLPixel24::Set(PLBYTE r, PLBYTE g, PLBYTE b)
00083 {
00084 m_Data[PL_RGBA_RED] = r;
00085 m_Data[PL_RGBA_GREEN] = g;
00086 m_Data[PL_RGBA_BLUE] = b;
00087 }
00088
00089
00090 inline void PLPixel24::SetR(PLBYTE r)
00091 {
00092 m_Data[PL_RGBA_RED] = r;
00093 }
00094
00095
00096 inline void PLPixel24::SetG(PLBYTE g)
00097 {
00098 m_Data[PL_RGBA_GREEN] = g;
00099 }
00100
00101
00102 inline void PLPixel24::SetB(PLBYTE b)
00103 {
00104 m_Data[PL_RGBA_BLUE] = b;
00105 }
00106
00107
00108 inline PLBYTE PLPixel24::GetR() const
00109 {
00110 return m_Data[PL_RGBA_RED];
00111 }
00112
00113
00114 inline PLBYTE PLPixel24::GetG() const
00115 {
00116 return m_Data[PL_RGBA_GREEN];
00117 }
00118
00119
00120 inline PLBYTE PLPixel24::GetB() const
00121 {
00122 return m_Data[PL_RGBA_BLUE];
00123 }
00124
00125
00126 inline int PLPixel24::BoxDist (const PLPixel24 Pix) const
00127 {
00128 return (abs ((int)GetR()-Pix.GetR()) +
00129 abs ((int)GetG()-Pix.GetG()) +
00130 abs ((int)GetB()-Pix.GetB()));
00131 }
00132
00133
00134 inline PLPixel24 PLPixel24::Blend (int Factor, const PLPixel24 Pix1, const PLPixel24 Pix2)
00135 {
00136 PLASSERT (Factor >= 0 && Factor <= 256);
00137
00138 return PLPixel24 ((Pix1.GetR()*Factor+Pix2.GetR()*(256-Factor))>>8,
00139 (Pix1.GetG()*Factor+Pix2.GetG()*(256-Factor))>>8,
00140 (Pix1.GetB()*Factor+Pix2.GetB()*(256-Factor))>>8);
00141 }
00142
00143 inline PLPixel24 PLPixel24::operator = (const PLPixel32& Pix)
00144 {
00145 SetR (Pix.GetR());
00146 SetG (Pix.GetG());
00147 SetB (Pix.GetB());
00148
00149 return *this;
00150 }
00151
00152 inline PLPixel24::operator PLPixel32 () const
00153 {
00154 return PLPixel32 (GetR(), GetG(), GetB(), 255);
00155 }
00156
00157 inline bool PLPixel24::operator ==(const PLPixel24& Pix) const
00158 {
00159 return (GetR() == Pix.GetR() && GetG() == Pix.GetG() && GetB() == Pix.GetB());
00160 }
00161
00162 inline bool PLPixel24::operator !=(const PLPixel24& Pix) const
00163 {
00164 return (!(*this == Pix));
00165 }
00166
00167
00168 #endif
00169
00170
00171
00172
00173