[cairo] Problem with png in pdf documents when using acroread

Carl Worth cworth at cworth.org
Wed Apr 4 15:27:22 PDT 2007


On Wed, 4 Apr 2007 23:22:30 +0200, Davide Viti wrote:
> I also found out that if you fille the rectangle acroread has no problems
> showing it:

But you didn't just change cairo_stroke to cairo_fill here. What you
had before was:

	cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);

	for (i = 0; i < 2; i++)
	{
	    cairo_rectangle(cr, 100, 100, 150, 150 );
	    cairo_stroke(cr);
	    ...
	    cairo_set_source_surface (cr, image, 30, 30);
	    ...
	    cairo_show_page (cr);
	}

and after the change:

	cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);

	for (i = 0; i < 2; i++)
	{
	    cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);
	    cairo_rectangle(cr, 100, 100, 150, 150 );
	    cairo_fill(cr);

	    cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
	    cairo_rectangle(cr, 100, 100, 150, 150 );
	    cairo_stroke(cr);
	    ...
	    cairo_set_source_surface (cr, image, 30, 30);
	    ...
	    cairo_show_page(cr);
	}

So, more important than the addition of the call to cairo_fill is the
addition of the call to cairo_set_source_rgb before the call to
cairo_stroke (and inside the loop). As mentioned elsewhere in the
thread, without this call, the second iteration of the first loop
above strokes the rectangle while still having the image as the source
pattern rather than having a solid black source pattern.

Now, that's clearly a bug in your program with respect to what you
were attempting to draw.

But in spite of your original program not expressing your intent, the
correct behavior of that program is still well-defined. And the two
viewers should render the PDF file consistently. So, maybe the
original result actually indicates a bug in xpdf since it displayed
what you _expected_ instead of what your program actually _expressed_.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070404/a01ebb07/attachment.pgp


More information about the cairo mailing list