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;
}
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;
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);
&rrect,
djvu_document->d_format,
gdk_pixbuf_get_rowstride (pixbuf),
- gdk_pixbuf_get_pixels (pixbuf));
+ (gchar *)gdk_pixbuf_get_pixels (pixbuf));
-
- return pixbuf;
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
+ g_object_unref (pixbuf);
+
+ return rotated_pixbuf;
}
static void
G_OBJECT_CLASS (djvu_document_parent_class)->finalize (object);
}
-static void
-djvu_document_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- /* read only */
- break;
- }
-}
-
-static void
-djvu_document_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- switch (prop_id)
- {
- case PROP_TITLE:
- g_value_set_string (value, NULL);
- break;
- }
-}
-
static void
djvu_document_class_init (DjvuDocumentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = djvu_document_finalize;
- gobject_class->get_property = djvu_document_get_property;
- gobject_class->set_property = djvu_document_set_property;
-
- g_object_class_override_property (gobject_class, PROP_TITLE, "title");
}
static gboolean
return FALSE;
}
+static EvDocumentInfo *
+djvu_document_get_info (EvDocument *document)
+{
+ EvDocumentInfo *info;
+
+ info = g_new0 (EvDocumentInfo, 1);
+
+ return info;
+}
+
static void
djvu_document_document_iface_init (EvDocumentIface *iface)
{
iface->get_n_pages = djvu_document_get_n_pages;
iface->get_page_size = djvu_document_get_page_size;
iface->render_pixbuf = djvu_document_render_pixbuf;
+ iface->get_info = djvu_document_get_info;
}
static void
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;
- gchar *pixels;
+ guchar *pixels;
g_return_val_if_fail (djvu_document->d_document, NULL);
djvu_document_thumbnails_get_dimensions (document, page, width, &thumb_width, &thumb_height);
- if (border) {
- pixbuf = ev_document_misc_get_thumbnail_frame (thumb_width, thumb_height, NULL);
- pixels = gdk_pixbuf_get_pixels (pixbuf) + gdk_pixbuf_get_rowstride (pixbuf) + 4;
- } else {
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- thumb_width, thumb_height);
- gdk_pixbuf_fill (pixbuf, 0xffffffff);
- pixels = gdk_pixbuf_get_pixels (pixbuf);
- }
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+ thumb_width, thumb_height);
+ gdk_pixbuf_fill (pixbuf, 0xffffffff);
+ 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),
- pixels);
+ (gchar *)pixels);
+
+ rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
+ g_object_unref (pixbuf);
+
+ if (border) {
+ GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
+ rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
+ g_object_unref (tmp_pixbuf);
+ }
- return pixbuf;
+ return rotated_pixbuf;
}
static void