From e48cf2858b65aa026771a48d2b315cbc663d8234 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Wed, 05 Jan 2005 02:42:04 +0000 Subject: Do real thumbnailing of PDF files. It's slow, but I'll speed it up next! Tue Jan 4 21:25:05 2005 Jonathan Blandford * pdf/xpdf/pdf-document.cc: Do real thumbnailing of PDF files. It's slow, but I'll speed it up next! --- diff --git a/ChangeLog b/ChangeLog index 0a293c7..57c0f41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Jan 4 21:25:05 2005 Jonathan Blandford + + * pdf/xpdf/pdf-document.cc: Do real thumbnailing of PDF files. + It's slow, but I'll speed it up next! + 2005-01-04 Jeff Muizelaar * shell/main.c (load_files): diff --git a/pdf/xpdf/GDKSplashOutputDev.cc b/pdf/xpdf/GDKSplashOutputDev.cc index 4ef3bb3..90f8811 100644 --- a/pdf/xpdf/GDKSplashOutputDev.cc +++ b/pdf/xpdf/GDKSplashOutputDev.cc @@ -90,7 +90,7 @@ void GDKSplashOutputDev::endPage() { } void GDKSplashOutputDev::dump() { - if (incrementalUpdate) { + if (incrementalUpdate && redrawCbk) { (*redrawCbk)(redrawCbkData); } } @@ -155,6 +155,10 @@ void GDKSplashOutputDev::redraw(int srcX, int srcY, g_free (gdk_buf); } +void GDKSplashOutputDev::drawToPixbuf(GdkPixbuf *pixbuf, int pageNum) { + +} + GBool GDKSplashOutputDev::findText(Unicode *s, int len, GBool startAtTop, GBool stopAtBottom, GBool startAtLast, GBool stopAtLast, diff --git a/pdf/xpdf/GDKSplashOutputDev.h b/pdf/xpdf/GDKSplashOutputDev.h index 753ef93..6ab769a 100644 --- a/pdf/xpdf/GDKSplashOutputDev.h +++ b/pdf/xpdf/GDKSplashOutputDev.h @@ -73,6 +73,8 @@ public: int destX, int destY, int width, int height); + void drawToPixbuf(GdkPixbuf *pixbuf, int pageNum); + // Find a string. If is true, starts looking at the // top of the page; else if is true, starts looking // immediately after the last find result; else starts looking at diff --git a/pdf/xpdf/pdf-document.cc b/pdf/xpdf/pdf-document.cc index 820a171..51ade18 100644 --- a/pdf/xpdf/pdf-document.cc +++ b/pdf/xpdf/pdf-document.cc @@ -1013,6 +1013,43 @@ pdf_document_document_bookmarks_iface_init (EvDocumentBookmarksIface *iface) /* Thumbnails */ static GdkPixbuf * +pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document, + gdouble scale_factor, + gint page_num, + gint width, + gint height) +{ + GdkPixmap *pixmap; + GDKSplashOutputDev *output; + GdkPixbuf *pixbuf; + + pixmap = gdk_pixmap_new (pdf_document->target, + width, height, -1); + + output = new GDKSplashOutputDev (gdk_drawable_get_screen (pdf_document->target), + NULL, NULL); + output->startDoc (pdf_document->doc->getXRef()); + pdf_document->doc->displayPage (output, + page_num + 1, + 72*scale_factor, + 72*scale_factor, + 0, gTrue, gFalse); + output->redraw (0, 0, + pixmap, + 0, 0, + width, height); + pixbuf = gdk_pixbuf_get_from_drawable (NULL, + pixmap, + NULL, + 0, 0, + 0, 0, + width, height); + gdk_drawable_unref (pixmap); + delete output; + return pixbuf; +} + +static GdkPixbuf * pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, gint page, gint width) @@ -1054,13 +1091,19 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails thumbnail = tmp_pixbuf; } else { gdouble page_ratio; + gdouble scale_factor; gint dest_height; page_ratio = the_page->getHeight () / the_page->getWidth (); + scale_factor = (gdouble)width / the_page->getWidth (); dest_height = (gint) (width * page_ratio); - - thumbnail = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, dest_height); - gdk_pixbuf_fill (thumbnail, 0xffffffff); + + thumbnail = pdf_document_thumbnails_get_page_pixbuf (pdf_document, + scale_factor, + page, + width, + dest_height); + /* FIXME: Actually get the image... */ } diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c index 8bd7879..a80f24e 100644 --- a/shell/ev-sidebar-thumbnails.c +++ b/shell/ev-sidebar-thumbnails.c @@ -143,9 +143,9 @@ do_one_iteration (EvSidebarThumbnails *ev_sidebar_thumbnails) GtkTreeIter iter; tmp = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (priv->document), - priv->current_page, THUMBNAIL_WIDTH); + priv->current_page, THUMBNAIL_WIDTH); -#if 1 +#if 0 /* Don't add the shadow for now, as it's really slow */ pixbuf = g_object_ref (tmp); #else -- cgit v0.9.1