[cairo] downscaling capabilities

Owen Taylor otaylor at redhat.com
Sat Apr 19 15:12:54 PDT 2008


On Sat, 2008-04-19 at 12:16 -0700, Bill Spitzak wrote:
> > Owen Taylor a écrit :
> 
> >> I'm going to directly disagree here and suggest that for
> >> CAIRO_FILTER_GOOD, the right algorithm is:
> >>
> >>  - Scale down by factors of 2 repeatedly until you are less than 2 times
> >>    the target scale factor
> >>  - Bilinearly sample from the result
> >>
> >> There are certainly disadvantages to this to this approach:
> >>
> >>  - Works worse with non-uniform scales (that contract more in one
> >>    direction than others)
> 
> If you are going to do this each time it is quite possible to use a 
> different power of 2 horizontally than vertically.

For pure scales, yes. But the transform could also contract the image
at a 45 degree angle to the axes.

> Actually I think if you are calculating this each time than you can do 
> any integer, not just a power of 2, and the speed is pretty much the 
> same? I do agree that an integer scale with a box filter is far faster 
> than any other kind of filtering.

Yep. Locality is a bit more of an issue, overflow will be an issue at
some point (especially with mmx). I don't know offhand how a scale
down of 2.7 times looks with bilinear interpolation from a 
2-times downscaled copy vs. a 3-time downscaled copy... if there is
a significant improvement or not.

- Owen




More information about the cairo mailing list