[cairo] Strange bug (?) when painting/cropping recording surface to PDF surface

Bernhard R. Fischer bf at abenteuerland.at
Mon Apr 11 05:49:12 UTC 2016


On 2016-04-10 09:28, Adrian Johnson wrote:
> On 10/04/16 03:25, Bernhard R. Fischer wrote:
>> Hi!
>>
>> _Background_
>> In my project a record all drawing operations to a recording surface.
>> Finally, to output files I create surfaces of specific backends (PNG,
>> PDF, and SVG) and "crop" (the final surface is smaller than the
>> recording source surface), rotate, and paint the recording surface to it.
>>
>>
>> _Strange Behavior_
>> When using PDF as backend, not everything is painted from the source
>> (recording) surface to the PDF surface. On PNG and SVG it works as expected.
>>
>>
>> _Examples_
>> There is a PNG and PDF example to show the behavior. Look at the right
>> lower corner: right of the string "015°30" the short black lines in the
>> axis are missing compared to the PNG.
>> http://www.abenteuerland.at/download/eagle/output.pdf
>> http://www.abenteuerland.at/download/eagle/output.png
>>
>>
>> _Trigger_
>> I observed, that this behavior is triggered as soon as the PDF surface
>> is smaller than the recording surface.
>>
>>
>> _Code Snippet_
>> The following code snippets shows how I create the PDF and PNG surface
>> from the recording surface (sfc_).
>>
>>
>> 	/* create PDF from sfc_ */
>> 	sfc = cairo_pdf_surface_create("output.pdf", width*.7, height*1.3);
>> 	dst = cairo_create(sfc);
>> 	cairo_rotate(dst, DEG2RAD(15));
>> 	cairo_set_source_surface(dst, sfc_, 0, 0);
>>         cairo_paint(dst);
>>         cairo_show_page(dst);
>>         cairo_destroy(dst);
>>         cairo_surface_destroy(sfc);
>>
>>
>> 	/* create PNG from sfc_ */
>>          sfc = cairo_image_surface_create(CAIRO_FORMAT_RGB24, width*.7,
>> height*1.3);
>>          dst = cairo_create(sfc);
>>          cairo_rotate(dst, DEG2RAD(15));
>>          cairo_set_source_surface(dst, sfc_, 0, 0);
>>          cairo_paint(dst);
>>          cairo_show_page(dst);
>>          cairo_destroy(dst);
>>          cairo_surface_write_to_png(sfc, "output.png");
>>          cairo_surface_destroy(sfc);
>>
>>
>> Any hints appreciated.
> 
> If you can provide a simple test case that reproduces the bug with the
> current version of cairo I can look into it.
> 

Hi!

Please find attached a simple test program which demonstrates it.
I tested it on Cairo 1.14.6 and 1.14.0.


Bernhard


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rec_test.c
Type: text/x-csrc
Size: 2167 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20160411/214fe125/attachment.c>


More information about the cairo mailing list