[cairo] Render to image buffer artifacts

Carl Worth cworth at cworth.org
Fri Jan 7 15:28:56 PST 2005


On Fri, 07 Jan 2005 17:42:04 -0500, Chris wrote:
> Is it worthwhile to continue to post this stuff?

I've seen this bug before, but I hadn't put a lot of effort into it
since the artifacts were rarely visible, (usually requiring careful
inspection of the bytes), and I've assumed that the new tessellator
will take care of it.

But the behavior is annoying, and now that someone else has noticed
I'm looking closer.

I've distilled your first image down to the following fairly-minimal
test, and I'm now checking to see if the bug is in the tessellation or
rasterization.

-Carl

-------------- next part --------------
/* cc -o leaky_spline `pkg-config --cflags --libs cairo` leaky_spline.c */

#include <stdio.h>
#include <math.h>
#include <cairo.h>

#define WIDTH 21
#define HEIGHT 21

static void
draw (cairo_t *cr)
{
    cairo_move_to (cr, 2, .6);
    cairo_rel_curve_to (cr,
			 0, 10,
			10, 19.16,
			16, 19.16);

    cairo_set_rgb_color (cr, 1, 1, 1);
    cairo_fill (cr);
}

int
main (int argc, char* argv[])
{
    int i, j;
    cairo_t* cr;
    char* data = 0;
    char* pos;

    cr = cairo_create ();
    data = calloc (1, WIDTH*HEIGHT*4);
    cairo_set_target_image (cr, data, CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT, WIDTH*4);

    cairo_set_tolerance (cr, .1);
    draw (cr);
    cairo_destroy(cr);

    /* Print out alpha values */
    pos = data;
    for (i = 0; i < HEIGHT; i++)
    {
	for (j = 0; j < WIDTH; j++)
	{
	    printf("%.2X", *(pos+3) & 0xFF);
	    pos += 4;
	}

	printf("\n");
    }

    free(data);

    return 0;
}





More information about the cairo mailing list