[cairo] Cairo set_surface_source broken on image surface // was Cairo Win32 draws only some simple lines.
Edward Zimmermann
Edward.Zimmermann at cib.de
Tue Feb 12 01:52:12 PST 2013
I think there are some serious bugs in Cairo.
The code I posted here at the first of the month continues to fail--- and this on multiple platforms.
Here is the code again:
If TEST1 and TEST2 NOT defined --> Does what we expect
If only TEST1 is defined ---> Does what we expect
If only TEST2 is defined ---> Does what we expect
If both TEST1 and TEST2 are defined --> PNG is empty!
If instead of an image surface (XXX below) we use a vector surface such as PDF, SVG, PS it produces what we expect..
#include <cairo/cairo.h>
#define TEST1 1
#define TEST2 1
void main()
{
cairo_matrix_t rot = {0,-1,1,0,0,40};
cairo_rectangle_t r0rect = {0,0,40,40};
cairo_surface_t* r0 = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &r0rect);
cairo_t* c0 = cairo_create(r0);
cairo_set_source_rgba(c0,1,0,0,1);
cairo_rectangle(c0,0,0,20,20);
cairo_fill(c0);
cairo_set_source_rgba(c0,0,1,0,1);
cairo_rectangle(c0,20,0,20,20);
cairo_fill(c0);
cairo_set_source_rgba(c0,0,0,1,1);
cairo_rectangle(c0,0,20,20,20);
cairo_fill(c0);
cairo_set_source_rgba(c0,1,1,0,1);
cairo_rectangle(c0,20,20,20,20);
cairo_fill(c0);
cairo_rectangle_t r1rect = {0,0,40,40};
cairo_surface_t* r1 = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &r1rect);
cairo_t* c1 = cairo_create(r1);
#if TEST1
cairo_transform(c1, &rot);
#endif
cairo_set_source_surface(c1, r0, 0, 0);
cairo_paint(c1);
cairo_rectangle_t r2rect = {0,0,40,40};
cairo_surface_t* r2 = cairo_recording_surface_create(CAIRO_CONTENT_COLOR_ALPHA, &r2rect);
cairo_t* c2 = cairo_create(r2);
#if TEST2
cairo_transform(c2, &rot);
#endif
cairo_set_source_surface(c2, r1, 0, 0);
cairo_paint(c2);
cairo_surface_t* image = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 40, 40); /* XXXX */
cairo_t* ci = cairo_create(image);
cairo_set_source_surface(ci, r2, 0, 0);
cairo_paint(ci);
cairo_surface_write_to_png(image,"dummy.png");
}
More information about the cairo
mailing list