- crs = cairo_surface_write_to_png(cairo_get_target(cr), pngpath);
- if (crs != CAIRO_STATUS_SUCCESS) {
- fprintf(stderr,
- "cairo_surface_write_to_png failed: %s\n",
- cairo_status_to_string(crs));
- svgtiny_free(diagram);
- cairo_destroy(cr);
- return 1;
+ pb = gdk_pixbuf_get_from_surface(cairo_get_target(cr),
+ 0,
+ 0,
+ pngwidth,
+ pngheight);
+
+
+ if (pb) {
+ gdk_pixbuf_save(pb, pngpath, "png", NULL, NULL);
+ g_object_unref(pb);