[cairo] White seams (lines) appearing between objects

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Tue Jan 15 10:25:33 PST 2008


Carl Worth wrote:
[snip]
> If you replace the drawing of the "red"[*] rectangle image with the
> following code:
> 
>     cairo_rectangle (cr, 799.52, 464.32, 30, 160);
>     cairo_set_source_rgb (cr, 1, 0, 0);
>     cairo_fill (cr);
> 
> Then there is no longer any seam at all.
> 
> So something about the non-antialiased sampling of the image is giving
> a result that is different than just rendering a rectangle with the
> same geometry.

May I suggest that it's the rendering of the rectangle that's odd here,
and not the sampling of the image?

To see what I mean, add the following code to your testcase:

    // draw some reference lines.
    cairo_rectangle (cr, PAD-1, 0, 1, PAD + IMAGE_WIDTH + PAD);
    cairo_rectangle (cr, PAD + IMAGE_WIDTH, 0, 1, PAD + IMAGE_WIDTH + PAD);
    cairo_rectangle (cr, 0, PAD-1, PAD + IMAGE_WIDTH + PAD, 1);
    cairo_rectangle (cr, 0, PAD + IMAGE_WIDTH, PAD + IMAGE_WIDTH + PAD, 1);
    cairo_set_source_rgb (cr, 0, 1, 0); /* green */
    cairo_fill (cr);

For 0 < OFFSET < 0.5, both the red rectangle and the sampled image lie
within these reference lines. For 0.5 < OFFSET < 1, however, the
sampled image is shifted by 1 in both the x and y directions, while
the red rectangle is only shifted in the y direction.

OFFSET=0.5 is a boundary case, it's hard to get this correct.

regards,

Bertram


More information about the cairo mailing list