diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 19:27:49 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-11-05 19:27:49 +0000 |
commit | 34564aa84a4642dceba75efdeef438be6c6896c8 (patch) | |
tree | efd320befa6888dc91a73335c961d83eaf8c33ae /test/pdf2png.c | |
parent | 564d64a1323c5cbcde2dd9365ac790fe8aa1c5a6 (diff) |
[test/pdf2png] Remove dependency on GdkPixbuf
It's appears to be dropped from the current poppler trunk, so just use our
own venerable cairo_surface_write_ton_png().
Diffstat (limited to 'test/pdf2png.c')
-rw-r--r-- | test/pdf2png.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/test/pdf2png.c b/test/pdf2png.c index 543a996e2..8471a186d 100644 --- a/test/pdf2png.c +++ b/test/pdf2png.c @@ -36,21 +36,21 @@ int main (int argc, char *argv[]) { PopplerDocument *document; PopplerPage *page; - GdkPixbuf *pixbuf; double width, height; - GError *error; const char *filename = argv[1]; const char *output_filename = argv[2]; const char *page_label = argv[3]; gchar *absolute, *uri; + cairo_surface_t *surface; + cairo_t *cr; + cairo_status_t status; + GError *error = NULL; if (argc != 4) FAIL ("usage: pdf2png input_file.pdf output_file.png page"); g_type_init (); - error = NULL; - if (g_path_is_absolute(filename)) { absolute = g_strdup (filename); } else { @@ -74,16 +74,22 @@ int main (int argc, char *argv[]) poppler_page_get_size (page, &width, &height); - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, - width * PIXELS_PER_POINT, - height * PIXELS_PER_POINT); - gdk_pixbuf_fill (pixbuf, 0xffffffff); - poppler_page_render_to_pixbuf (page, 0, 0, width , height, - PIXELS_PER_POINT, 0, pixbuf); + surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height); + cr = cairo_create (surface); + cairo_surface_destroy (surface); - gdk_pixbuf_save (pixbuf, output_filename, "png", &error, NULL); - if (error != NULL) - FAIL (error->message); + cairo_set_source_rgb (cr, 1., 1., 1.); + cairo_paint (cr); + + poppler_page_render (page, cr); + g_object_unref (page); + + status = cairo_surface_write_to_png (cairo_get_target (cr), + output_filename); + cairo_destroy (cr); + + if (status) + FAIL (cairo_status_to_string (status)); return 0; } |