fix bicubic stretch interpolation

This commit is contained in:
homm 2014-10-24 12:46:51 +04:00
parent 9634e437ef
commit c2d688c4b6

View File

@ -64,16 +64,14 @@ static struct filter BILINEAR = { bilinear_filter, 1.0 };
static inline float bicubic_filter(float x)
{
/* FIXME: double-check this algorithm */
/* FIXME: for best results, "a" should be -0.5 to -1.0, but we'll
set it to zero for now, to match the 1.1 magnifying filter */
#define a 0.0
/* http://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm */
#define a -1.0
if (x < 0.0)
x = -x;
if (x < 1.0)
return (((a + 2.0) * x) - (a + 3.0)) * x*x + 1;
return ((a + 2.0) * x - (a + 3.0)) * x*x + 1;
if (x < 2.0)
return (((a * x) - 5*a) * x + 8) * x - 4*a;
return (((x - 5) * x + 8) * x - 4) * a;
return 0.0;
#undef a
}