[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().
This commit is contained in:
Chris Wilson 2008-11-05 19:27:49 +00:00
parent 564d64a132
commit 34564aa84a
2 changed files with 20 additions and 14 deletions

View file

@ -391,7 +391,7 @@ test_pdf=no
any2ppm_pdf=no
if test "x$use_pdf" = "xyes"; then
poppler_DEPENDENCY="poppler-glib >= $POPPLER_VERSION_REQUIRED"
PKG_CHECK_MODULES(POPPLER, $poppler_DEPENDENCY pango gtk+-2.0,
PKG_CHECK_MODULES(POPPLER, $poppler_DEPENDENCY,
[CAIRO_CHECK_FUNCS_WITH_FLAGS(poppler_page_render, [$POPPLER_CFLAGS], [$POPPLER_LIBS],
[test_pdf=yes; any2ppm_pdf=yes],
[AC_MSG_RESULT(no); test_pdf="no (requires $poppler_DEPENDENCY)"])],

View file

@ -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;
}