[cairo] image downsampling quality

Søren Sandmann sandmann at cs.au.dk
Thu Jan 2 12:56:01 PST 2014


Krzysztof Kosiński <tweenk.pl at gmail.com> writes:

>> I think it's bilinear, which means if you are reducing to less than 50%, it
>> misses pixels.
>>
>> There's been tons of talk and patches to fix this in pixman over the years.
>> I'm not sure what the current status is.
>
> The current trunk is fixed, and uses Lanczos3 downsampling for
> CAIRO_FILTER_BEST.

If I'm reading the code in cairo-image-source.c right, then the 'BEST'
case is missing a break so that it falls through to GAUSSIAN and then to
default, which then seems to use a box filter for sampling and a
bilinear filter for reconstruction.

It also looks like, if a "break" were to be added, that the BEST filter
would use LANCZOS3 for both sampling and reconstruction which would
pointlessly make the filter bigger (and therefore slower) in the common
cases of a pure upscaling or downscaling.

(It can make sense to use a box filter for both reconstruction and
sampling because a box filter is such a poor filter, but Lanczos3 is a
good enough filter that it's safe to pair it with Impulse as long as the
transformation is a pure downscaling or upscaling).
 
However, I won't pretend to understand what's going on in that function.


Søren


More information about the cairo mailing list