Created a simple harsh filter.
This demonstrates how easy it is to add a filter using this framework
This commit is contained in:
parent
dc28fae625
commit
5fcdce361a
|
@ -285,6 +285,7 @@ SET(SRC_FILTERS
|
||||||
src/filters/filter_functions/simpleFilter.cpp
|
src/filters/filter_functions/simpleFilter.cpp
|
||||||
src/filters/filter_functions/sdl.cpp
|
src/filters/filter_functions/sdl.cpp
|
||||||
src/filters/filter_functions/xBRZ/xbrz.cpp
|
src/filters/filter_functions/xBRZ/xbrz.cpp
|
||||||
|
src/filters/filter_functions/harsh.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(SRC_HQ_C
|
SET(SRC_HQ_C
|
||||||
|
|
|
@ -108,6 +108,10 @@ filter_base * filter_factory::createFilter(std::string filterName,unsigned int w
|
||||||
{
|
{
|
||||||
return new MotionBlurIB(width,height);
|
return new MotionBlurIB(width,height);
|
||||||
}
|
}
|
||||||
|
if("Harsh" == filterName)
|
||||||
|
{
|
||||||
|
return new harsh(width,height);
|
||||||
|
}
|
||||||
|
|
||||||
//If nothing found, just return a default filter
|
//If nothing found, just return a default filter
|
||||||
return new filter_base(width,height);
|
return new filter_base(width,height);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "../filters.hpp"
|
||||||
|
|
||||||
|
///Arthur's harsh filter
|
||||||
|
///All colors are either off or full color
|
||||||
|
void harsh::run(u32 *srcPtr,u32 *dstPtr)
|
||||||
|
{
|
||||||
|
unsigned int numPixels = this->getWidth() * this->getHeight();
|
||||||
|
for(unsigned int i=0;i<numPixels;++i)
|
||||||
|
{
|
||||||
|
u8* pixelIn = (u8*)(&srcPtr[i]);
|
||||||
|
u8* pixelOut = (u8*)(&dstPtr[i]);
|
||||||
|
//For each pixel set it to 0x00 or 0xff
|
||||||
|
//Last is an alpha channel which is ignored
|
||||||
|
for(unsigned int i = 0; i<3; i++)
|
||||||
|
{
|
||||||
|
if(pixelIn[i] < 128)
|
||||||
|
{
|
||||||
|
pixelOut[i] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pixelOut[i] = 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -73,6 +73,21 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
///Arthur's harsh filter
|
||||||
|
///All colors are either off or full color
|
||||||
|
class harsh : public filter_base
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
//Must enter width and height at filter initialization
|
||||||
|
harsh();
|
||||||
|
public:
|
||||||
|
harsh(unsigned int _width,unsigned int _height): filter_base(_width,_height) {}
|
||||||
|
~harsh(){}
|
||||||
|
std::string getName() {return "Harsh";};
|
||||||
|
bool exists() {return true;}
|
||||||
|
void run(u32 *srcPtr,u32 *dstPtr);
|
||||||
|
};
|
||||||
|
|
||||||
//These are the available filters
|
//These are the available filters
|
||||||
|
|
||||||
//wx
|
//wx
|
||||||
|
|
Loading…
Reference in New Issue