Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2005-01-05 02:42:04 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-01-05 02:42:04 (GMT)
commite48cf2858b65aa026771a48d2b315cbc663d8234 (patch)
tree390d0b8699f36874eaa7c8a77e3917632864eac0
parenta88a1cde73b054120966e67bc0ad361457c5b4d2 (diff)
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 <jrb@redhat.com> * pdf/xpdf/pdf-document.cc: Do real thumbnailing of PDF files. It's slow, but I'll speed it up next!
-rw-r--r--ChangeLog5
-rw-r--r--pdf/xpdf/GDKSplashOutputDev.cc6
-rw-r--r--pdf/xpdf/GDKSplashOutputDev.h2
-rw-r--r--pdf/xpdf/pdf-document.cc49
-rw-r--r--shell/ev-sidebar-thumbnails.c4
5 files changed, 60 insertions, 6 deletions
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 <jrb@redhat.com>
+
+ * 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 <jrmuizel@nit.ca>
* 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 <startAtTop> is true, starts looking at the
// top of the page; else if <startAtLast> 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