cairo recording surface leaves target surface empty
Martin Kalbfuß <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <1318547494.6955.4.camel@martin-K7VT4APro> |
Hi folks, I try to use the recording surface of cairo. But when I draw it onto another surface, there's nothing. What's wrong here? Im new to cairo. So it's going to be a stupid mistake. :-P Source and bitmap are appended. Thanks, Martin Kalbfuß -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo
cairo_test2.c
(text/x-csrc, 994 B)
#include <stdlib.h>
#include <stdio.h>
#include <cairo/cairo.h>
int main(void)
{
cairo_surface_t *record = cairo_recording_surface_create(CAIRO_CONTENT_COLOR, NULL);
cairo_t *record_cr = cairo_create(record);
cairo_set_source_rgb(record_cr, 1, 0, 0);
cairo_rectangle(record_cr, 10, 10, 100, 100);
cairo_fill(record_cr);
cairo_set_source_rgb(record_cr, 0, 1, 0);
cairo_rectangle(record_cr, 50, 50, 140, 140);
cairo_fill(record_cr);
double x0, y0, width, height;
cairo_recording_surface_ink_extents(record, &x0, &y0, &width, &height);
printf("x: %lf, y: %lf, w: %lf, h: %lf\n", x0, y0, width, height);
cairo_surface_t *output = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(output);
cairo_set_source_surface(cr, record, 0, 0);
cairo_paint(cr);
cairo_surface_write_to_png(output, "out.png");
cairo_destroy(record_cr);
cairo_destroy(cr);
cairo_surface_destroy(record);
cairo_surface_destroy(output);
return EXIT_SUCCESS;
}
out.png
(image/png, 222 B) - not displayed