00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef INCL_FILTERPIXEL
00012 #define INCL_FILTERPIXEL
00013
00014 #if _MSC_VER > 1000
00015 #pragma once
00016 #endif
00017
00018 #include "plfilter.h"
00019
00020 #include "plpixel32.h"
00021 #include "plpixel24.h"
00022 #include "plpixel8.h"
00023
00024 #include <typeinfo.h>
00025
00026 template <class PixelC, class PixelOp>
00027 class PLFilterPixel : public PLFilter
00028 {
00029 public:
00030 PLFilterPixel(const PixelOp & Op);
00031
00032 virtual ~PLFilterPixel();
00033
00034 void ApplyInPlace(PLBmp * pBmp) const;
00035
00036 private:
00037 PixelOp m_Op;
00038 };
00039
00040 template <class PixelC, class PixelOp>
00041 PLFilterPixel<PixelC, PixelOp>::PLFilterPixel
00042 (const PixelOp & Op)
00043 : m_Op (Op)
00044 {
00045 }
00046
00047 template <class PixelC, class PixelOp>
00048 PLFilterPixel<PixelC, PixelOp>::~PLFilterPixel ()
00049 {
00050 }
00051
00052 template <class PixelC, class PixelOp>
00053 void PLFilterPixel<PixelC, PixelOp>::ApplyInPlace (PLBmp *pBmp) const
00054 {
00055 PixelC** ppLines = (PixelC**)(pBmp->GetLineArray());
00056
00057 switch (pBmp->GetBitsPerPixel())
00058 {
00059 case 32:
00060 PLASSERT (typeid(PixelC) == typeid (PLPixel32));
00061 break;
00062 case 24:
00063 PLASSERT (typeid(PixelC) == typeid (PLPixel24));
00064 break;
00065 case 8:
00066 PLASSERT (typeid(PixelC) == typeid (PLPixel8));
00067 break;
00068 default:
00069 PLASSERT (false);
00070 }
00071
00072 for (int y=0; y<pBmp->GetHeight(); ++y)
00073 {
00074 PixelC* pLine = ppLines[y];
00075 for (int x=0; x<pBmp->GetWidth(); ++x)
00076 pLine[x] = m_Op.Apply(pLine[x]);
00077 }
00078 }
00079
00080 #endif
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100