2006-03-04 16:26:09 +01:00
|
|
|
|
// This file is part of FexGenericFilter and (C) 2006 by Hajo Krabbenh<6E>ft (tentacle)
|
|
|
|
|
// All rights reserved but the aegisub project is allowed to use it.
|
|
|
|
|
|
2006-03-03 20:00:47 +01:00
|
|
|
|
{
|
|
|
|
|
double width = FilterWidth;
|
|
|
|
|
#ifdef CONTRIB_XSCALE
|
|
|
|
|
width /= XScale;
|
|
|
|
|
double fscale = 1.0 / XScale;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<ImageOutSX;++i)
|
|
|
|
|
{
|
|
|
|
|
double center = (double) i / XScale;
|
|
|
|
|
FexFilterContribution* cc = &Contrib[i];
|
|
|
|
|
int left = (int) ceil(center - width);
|
|
|
|
|
int right = (int) (floor(center + width) + 0.1);
|
|
|
|
|
|
|
|
|
|
cc->xMin = left;
|
|
|
|
|
cc->xMax = right;
|
|
|
|
|
if( cc->xMin < 0 ) cc->xMin = 0;
|
|
|
|
|
if( cc->xMax > ImageInSX-1 ) cc->xMax = ImageInSX - 1;
|
|
|
|
|
|
|
|
|
|
int len = cc->xMax-cc->xMin+1;
|
|
|
|
|
cc->Weight = new double[ len ];
|
|
|
|
|
memset( cc->Weight, 0x00, sizeof(double)*len );
|
|
|
|
|
|
|
|
|
|
for(int j=left;j<=right;++j) {
|
|
|
|
|
double weight = center - (double) j;
|
|
|
|
|
#ifdef CONTRIB_XSCALE
|
|
|
|
|
weight = FilterWeight(weight / fscale) / fscale;
|
|
|
|
|
#else
|
|
|
|
|
weight = FilterWeight(weight);
|
|
|
|
|
#endif
|
|
|
|
|
int n;
|
|
|
|
|
if(j < 0) n=0;
|
|
|
|
|
else if(j >= ImageInSX) n = ImageInSX - 1;
|
|
|
|
|
else n = j;
|
|
|
|
|
cc->Weight[n-cc->xMin] += weight;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-31 00:09:33 +01:00
|
|
|
|
}
|
|
|
|
|
|