mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 14:16:00 +01:00
djvu support rotation
This commit is contained in:
parent
ace7e41a17
commit
19637bcd54
2 changed files with 55 additions and 13 deletions
|
@ -243,17 +243,39 @@ djvu_page_render(zathura_page_t* page)
|
|||
page_width, page_height, 3 * page_width, NULL, NULL);
|
||||
|
||||
if(!pixbuf) {
|
||||
free(buffer);
|
||||
g_object_unref(pixbuf);
|
||||
goto error_out;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
/* rotate page */
|
||||
if(Zathura.document->rotate != 0) {
|
||||
GdkPixbufRotation angle = GDK_PIXBUF_ROTATE_NONE;
|
||||
|
||||
switch(Zathura.document->rotate) {
|
||||
case 90:
|
||||
angle = GDK_PIXBUF_ROTATE_CLOCKWISE;
|
||||
break;
|
||||
case 180:
|
||||
angle = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
|
||||
break;
|
||||
case 270:
|
||||
angle = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
|
||||
break;
|
||||
default:
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
GdkPixbuf* pixbuf_temp = gdk_pixbuf_rotate_simple(pixbuf, Zathura.document->rotate);
|
||||
if(!pixbuf_temp) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
pixbuf = pixbuf_temp;
|
||||
}
|
||||
|
||||
GtkWidget* image = gtk_image_new();
|
||||
|
||||
if(!image) {
|
||||
free(buffer);
|
||||
g_object_unref(pixbuf);
|
||||
goto error_out;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
|
||||
|
@ -261,6 +283,11 @@ djvu_page_render(zathura_page_t* page)
|
|||
|
||||
return image;
|
||||
|
||||
error_free:
|
||||
|
||||
free(buffer);
|
||||
g_object_unref(pixbuf);
|
||||
|
||||
error_out:
|
||||
|
||||
return NULL;
|
||||
|
|
29
zathura.c
29
zathura.c
|
@ -101,6 +101,26 @@ document_close()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
page_render(zathura_page_t* page)
|
||||
{
|
||||
GtkWidget* image = zathura_page_render(page);
|
||||
if(!image) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
/* draw new rendered page */
|
||||
if(!girara_set_view(Zathura.UI.session, image)) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
error_out:
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
page_set(unsigned int page_id)
|
||||
{
|
||||
|
@ -114,12 +134,12 @@ page_set(unsigned int page_id)
|
|||
|
||||
/* render page */
|
||||
zathura_page_t* page = zathura_page_get(Zathura.document, page_id);
|
||||
|
||||
if(!page) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
GtkWidget* image = zathura_page_render(page);
|
||||
if(!image) {
|
||||
if(!page_render(page)) {
|
||||
zathura_page_free(page);
|
||||
fprintf(stderr, "error: rendering failed\n");
|
||||
goto error_out;
|
||||
|
@ -127,11 +147,6 @@ page_set(unsigned int page_id)
|
|||
|
||||
zathura_page_free(page);
|
||||
|
||||
/* draw new rendered page */
|
||||
if(!girara_set_view(Zathura.UI.session, image)) {
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
/* update page number */
|
||||
Zathura.document->current_page_number = page_id;
|
||||
|
||||
|
|
Loading…
Reference in a new issue