X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fpdf-document.cc;h=fc2568ba75b77f8e61ca05c020573c7748b821a2;hb=f06e050d41051f1ea95b40981aee32ef8e0b0bae;hp=57eafd134d9ae615ead19a144ab318b252f1c52c;hpb=d60348a1b1b0f5b9967dd4677118a94d1031171a;p=evince.git diff --git a/pdf/pdf-document.cc b/pdf/pdf-document.cc index 57eafd13..fc2568ba 100644 --- a/pdf/pdf-document.cc +++ b/pdf/pdf-document.cc @@ -140,7 +140,7 @@ document_display_page (PdfDocument *pdf_document) pdf_document->doc->displayPage (pdf_document->out, pdf_document->page, 72 * pdf_document->scale, 72 * pdf_document->scale, - 90, gTrue, gTrue); + 0, gTrue, gTrue); document_init_links (pdf_document); @@ -1240,7 +1240,8 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document, gdouble scale_factor, gint page_num, gint width, - gint height) + gint height, + gboolean border) { SplashOutputDev *output; GdkPixbuf *pixbuf; @@ -1251,15 +1252,24 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document, output = new SplashOutputDev (splashModeRGB8, gFalse, color); output->startDoc (pdf_document->doc->getXRef()); pdf_document->doc->displayPage (output, - page_num + 1, + page_num, 72*scale_factor, 72*scale_factor, 0, gTrue, gFalse); - pixbuf = ev_document_misc_get_thumbnail_frame (output->getBitmap()->getWidth(), - output->getBitmap()->getHeight(), - NULL); - bitmap_to_pixbuf (output->getBitmap(), pixbuf, 1, 1); + width = output->getBitmap()->getWidth(); + height = output->getBitmap()->getHeight(); + + if (border) { + pixbuf = ev_document_misc_get_thumbnail_frame (width, height, NULL); + bitmap_to_pixbuf (output->getBitmap(), pixbuf, 1, 1); + } else { + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, + width, height); + gdk_pixbuf_fill (pixbuf, 0xffffffff); + bitmap_to_pixbuf (output->getBitmap(), pixbuf, 0, 0); + } + delete output; return pixbuf; @@ -1268,7 +1278,7 @@ pdf_document_thumbnails_get_page_pixbuf (PdfDocument *pdf_document, static void pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnails, gint page, - gint suggested_width, + gint size, gint *width, gint *height) { @@ -1276,7 +1286,6 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail Page *the_page; Object the_thumb; Thumb *thumb = NULL; - gdouble page_ratio; the_page = pdf_document->doc->getCatalog ()->getPage (page); the_page->getThumb (&the_thumb); @@ -1289,16 +1298,26 @@ pdf_document_thumbnails_get_dimensions (EvDocumentThumbnails *document_thumbnail *width = thumb->getWidth (); *height = thumb->getHeight (); } else { - page_ratio = the_page->getHeight () / the_page->getWidth (); - *width = suggested_width; - *height = (gint) (suggested_width * page_ratio); + double page_width, page_height; + + page_width = the_page->getWidth (); + page_height = the_page->getHeight (); + + if (page_width > page_height) { + *width = size; + *height = (int) (size * page_height / page_width); + } else { + *width = (int) (size * page_width / page_height); + *height = size; + } } } static GdkPixbuf * pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails, gint page, - gint width) + gint size, + gboolean border) { PdfDocument *pdf_document = PDF_DOCUMENT (document_thumbnails); GdkPixbuf *thumbnail; @@ -1306,17 +1325,10 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails Object the_thumb; Thumb *thumb = NULL; gboolean have_ethumbs = FALSE; - gdouble page_ratio; - gint dest_height; - /* getPage seems to want page + 1 for some reason; */ - the_page = pdf_document->doc->getCatalog ()->getPage (page + 1); + the_page = pdf_document->doc->getCatalog ()->getPage (page); the_page->getThumb(&the_thumb); - page_ratio = the_page->getHeight () / the_page->getWidth (); - dest_height = (gint) (width * page_ratio); - - if (!(the_thumb.isNull () || the_thumb.isNone())) { /* Build the thumbnail object */ thumb = new Thumb(pdf_document->doc->getXRef (), @@ -1342,15 +1354,18 @@ pdf_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document_thumbnails thumbnail = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); g_object_unref (tmp_pixbuf); } else { - gdouble scale_factor; - - scale_factor = (gdouble)width / the_page->getWidth (); - + int width, height; + double scale_factor; + + pdf_document_thumbnails_get_dimensions (document_thumbnails, page, size, + &width, &height); + scale_factor = width / the_page->getWidth (); thumbnail = pdf_document_thumbnails_get_page_pixbuf (pdf_document, scale_factor, page, width, - dest_height); + height, + border); } return thumbnail;