[cairo] another pixman issue

Soeren Sandmann sandmann at daimi.au.dk
Mon Mar 24 07:04:13 PDT 2008


"Robert O'Callahan" <robert at ocallahan.org> writes:

> See attached test program. With pixman-0.9.6-43-gddfb69a, which includes
> Søren's "adjust" fix, the first row of pixels is
> 8d8d8d8d bebebebe bebebebe bebebebe bebebebe bebebebe bebebebe bebebebe
> 00000000 00000000
> So I wonder why in this case we're sampling outside the source image. I
> thought the purpose of "adjust" was to subtract an amount equal to half the
> size of a *source* pixel from 'v', but it appears to not be doing
> that.

A pixman image is an array of pixels, where the top left pixel has
coordinates (0.5, 0.5). But the scaling actually has (0, 0) as the
center and not (0.5, 0.5).

In your test case, the top left destination pixel with coordinates
(0.5, 0.5) gets transformed into (0.25, 0.25). The bilinear filter
then finds the four closest pixels to those coordinates:

   (-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5) and (0.5, 0.5). 

Three of these are outside the source image, so they are treated as
transparent. The last one is opaque white, so the result of the
resampling is a translucent gray.

The pixel with coordinates (n + 0.5, k + 0.5) is stored at k * stride
+ n, so the purpose of adjust is to subtract (0.5, 0.5) from the
transformed pixel so that the filtering code can pretend that pixels
actually have integer coordinates.


Soren



More information about the cairo mailing list