X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=djvu%2Fdjvu-document.c;h=19452499df704b0f4ad47d659034c75612ea84df;hb=1ba681aa9eb43a60f0a01c1939e70f9f6de755c7;hp=72be474bf3d76e9778b3d478cd312aa2362f618a;hpb=bf325e9279324f02bcadc0145cd553ed94c23d2d;p=evince.git diff --git a/djvu/djvu-document.c b/djvu/djvu-document.c index 72be474b..19452499 100644 --- a/djvu/djvu-document.c +++ b/djvu/djvu-document.c @@ -81,9 +81,11 @@ djvu_document_load (EvDocument *document, djvu_document->d_document = doc; - while (!ddjvu_document_decoding_done (djvu_document->d_document)) - ddjvu_message_wait (djvu_document->d_context); - + while (!ddjvu_document_decoding_done (djvu_document->d_document)) { + ddjvu_message_wait (djvu_document->d_context); + ddjvu_message_pop (djvu_document->d_context); + } + return TRUE; } @@ -114,30 +116,26 @@ djvu_document_get_page_size (EvDocument *document, double *height) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - - ddjvu_page_t *d_page; + ddjvu_pageinfo_t info; g_return_if_fail (djvu_document->d_document); - d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, page); - - while (!ddjvu_page_decoding_done (d_page)) - ddjvu_message_wait (djvu_document->d_context); + while (ddjvu_document_get_pageinfo(djvu_document->d_document, page, &info) < DDJVU_JOB_OK) { + ddjvu_message_wait (djvu_document->d_context); + ddjvu_message_pop (djvu_document->d_context); + } - if (width) - *width = ddjvu_page_get_width (d_page) * SCALE_FACTOR; - if (height) - *height = ddjvu_page_get_height (d_page) * SCALE_FACTOR; - - ddjvu_page_release (d_page); + *width = info.width * SCALE_FACTOR; + *height = info.height * SCALE_FACTOR; } static GdkPixbuf * djvu_document_render_pixbuf (EvDocument *document, - int page, gdouble scale) + EvRenderContext *rc) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); GdkPixbuf *pixbuf; + GdkPixbuf *rotated_pixbuf; ddjvu_rect_t rrect; ddjvu_rect_t prect; @@ -145,13 +143,15 @@ djvu_document_render_pixbuf (EvDocument *document, double page_width, page_height; - d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, page); + d_page = ddjvu_page_create_by_pageno (djvu_document->d_document, rc->page); - while (!ddjvu_page_decoding_done (d_page)) - ddjvu_message_wait (djvu_document->d_context); + while (!ddjvu_page_decoding_done (d_page)) { + ddjvu_message_wait (djvu_document->d_context); + ddjvu_message_pop (djvu_document->d_context); + } - page_width = ddjvu_page_get_width (d_page) * scale * SCALE_FACTOR; - page_height = ddjvu_page_get_height (d_page) * scale * SCALE_FACTOR; + page_width = ddjvu_page_get_width (d_page) * rc->scale * SCALE_FACTOR; + page_height = ddjvu_page_get_height (d_page) * rc->scale * SCALE_FACTOR; pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, page_width, page_height); @@ -166,8 +166,10 @@ djvu_document_render_pixbuf (EvDocument *document, gdk_pixbuf_get_rowstride (pixbuf), (gchar *)gdk_pixbuf_get_pixels (pixbuf)); - - return pixbuf; + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rc->rotation); + g_object_unref (pixbuf); + + return rotated_pixbuf; } static void @@ -243,11 +245,12 @@ djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, static GdkPixbuf * djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, gint page, + gint rotation, gint width, gboolean border) { DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf, *rotated_pixbuf; gint thumb_width, thumb_height; guchar *pixels; @@ -266,16 +269,21 @@ djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, pixels = gdk_pixbuf_get_pixels (pixbuf); } - while (ddjvu_thumbnail_status (djvu_document->d_document, page, 1) < DDJVU_JOB_OK) - ddjvu_message_wait (djvu_document->d_context); + while (ddjvu_thumbnail_status (djvu_document->d_document, page, 1) < DDJVU_JOB_OK) { + ddjvu_message_wait (djvu_document->d_context); + ddjvu_message_pop (djvu_document->d_context); + } ddjvu_thumbnail_render (djvu_document->d_document, page, &thumb_width, &thumb_height, djvu_document->d_format, gdk_pixbuf_get_rowstride (pixbuf), (gchar *)pixels); + + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rotation); + g_object_unref (pixbuf); - return pixbuf; + return rotated_pixbuf; } static void