00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "filterstatelesstrans.h"
00031 #include <cmath>
00032
00033 StatelessTransformationFilter::StatelessTransformationFilter() : ChannelFilter<unsigned char>()
00034 {
00035 active = false;
00036 x0 = y0 = 0;
00037 }
00038
00039 StatelessTransformationFilter::~StatelessTransformationFilter()
00040 {
00041 }
00042
00043 void StatelessTransformationFilter::OnMouseEvent(const int button, const int state, int x, int y)
00044 {
00045 if(button!=0)
00046 {
00047 return;
00048 }
00049 bool activity = active;
00050 ChannelFilter<unsigned char>::Normalize(&x,&y);
00051 if(!activity && state == 0 && button == 0)
00052 {
00053 active = true;
00054 x0 = x;
00055 y0 = y;
00056 }
00057 if(activity && state == 1 && button == 0)
00058 {
00059 active = false;
00060 Channel<unsigned char>* tmp = new Channel<unsigned char>(ChannelFilter<unsigned char>::GetHeight(),ChannelFilter<unsigned char>::GetWidth());
00061 OnTransform(ChannelFilter<unsigned char>::GetSubChannel(), tmp, x0, y0, x, y);
00062 for(int x1=0;x1<ChannelFilter<unsigned char>::GetWidth();x1++)
00063 for(int y1=0;y1<ChannelFilter<unsigned char>::GetHeight();y1++)
00064 ChannelFilter<unsigned char>::Set(x1,y1,tmp->Get(x1,y1));
00065 delete tmp;
00066 }
00067 }
00068
00069 unsigned char StatelessTransformationFilter::Get(const int x, const int y)
00070 {
00071 return(ChannelFilter<unsigned char>::Get(x,y));
00072 }
00073
00074 void StatelessTransformationFilter::Set(const int x, const int y, const unsigned char val)
00075 {
00076 ChannelFilter<unsigned char>::Set(x,y,val);;
00077 }
00078