#include <unistd.h> /* read */
#include <cairo.h>
+#include <gdk/gdk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <svgtiny.h>
/* Convenient typedefs for libsvgtiny */
return diagram;
}
-
/*
* @brief Create a cairo context from a libsvgtiny diagram.
*
return cr;
}
-
int main(int argc, char** argv) {
- int exit_code = 0;
-
char* svgpath;
char* pngpath;
int pngwidth = 1024, pngheight = 1024;
diagram_t* diagram;
- cairo_surface_t *surface;
cairo_t *cr = 0;
- cairo_status_t crs;
+
+ GdkPixbuf* pb;
/* Parse arguments, and maybe print usage */
if (argc < 3) {
return 1;
}
- 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);
}
return 0;