]> www.fi.muni.cz Git - evince.git/commitdiff
Do real thumbnailing of PDF files. It's slow, but I'll speed it up next!
authorJonathan Blandford <jrb@redhat.com>
Wed, 5 Jan 2005 02:42:04 +0000 (02:42 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 5 Jan 2005 02:42:04 +0000 (02:42 +0000)
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!

ChangeLog
pdf/xpdf/GDKSplashOutputDev.cc
pdf/xpdf/GDKSplashOutputDev.h
pdf/xpdf/pdf-document.cc
shell/ev-sidebar-thumbnails.c

index 0a293c759e3331d905f80267ccd294b5eb2a6ecc..57c0f417d6db8f850863e8a183ed45568ee1415b 100644 (file)
--- 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):
index 4ef3bb35f984cb76d11e065674eb4dca74ac3155..90f881197caa42c2e2ca9af78ec6f22a01e4a67f 100644 (file)
@@ -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,
index 753ef93fb6f3d38d00ab1a953d24a64184cd848c..6ab769a2809609705451afaca3f1f4413af6c45c 100644 (file)
@@ -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
index 820a17115b0d71cf3f395ef3966f61d9441fbd44..51ade189877dae2aefd5f1c8a98e62d7e60777cd 100644 (file)
@@ -1012,6 +1012,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,
@@ -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... */
        }
 
index 8bd7879a55a02798f2b66b9d26109fb0d1f7e545..a80f24e877ed9c46722d6ad21a5f5d7f337adbf4 100644 (file)
@@ -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