diff --git a/libImaging/Antialias.c b/libImaging/Antialias.c index d413fbb6a..e608ec8df 100644 --- a/libImaging/Antialias.c +++ b/libImaging/Antialias.c @@ -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 }