mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 22:25:59 +01:00
Update djvu/pdf render functions
This commit is contained in:
parent
7627c56d30
commit
abc7deadd3
2 changed files with 53 additions and 7 deletions
|
@ -196,8 +196,8 @@ djvu_page_render(zathura_page_t* page)
|
|||
}
|
||||
|
||||
/* calculate sizes */
|
||||
unsigned int page_width = page->width;
|
||||
unsigned int page_height = page->height;
|
||||
unsigned int page_width = Zathura.document->scale * page->width;
|
||||
unsigned int page_height = Zathura.document->scale * page->height;
|
||||
|
||||
/* init ddjvu render data */
|
||||
ddjvu_rect_t rrect = { 0, 0, page_width, page_height };
|
||||
|
@ -209,9 +209,9 @@ djvu_page_render(zathura_page_t* page)
|
|||
|
||||
switch(Zathura.document->rotate) {
|
||||
case 90:
|
||||
tmp = page_width;
|
||||
dim_temp = page_width;
|
||||
page_width = page_height;
|
||||
page_height = page_tmp;
|
||||
page_height = dim_temp;
|
||||
|
||||
rotation = DDJVU_ROTATE_90;
|
||||
break;
|
||||
|
@ -219,9 +219,9 @@ djvu_page_render(zathura_page_t* page)
|
|||
rotation = DDJVU_ROTATE_180;
|
||||
break;
|
||||
case 270:
|
||||
tmp = page_width;
|
||||
dim_temp = page_width;
|
||||
page_width = page_height;
|
||||
page_height = page_tmp;
|
||||
page_height = dim_temp;
|
||||
|
||||
rotation = DDJVU_ROTATE_270;
|
||||
break;
|
||||
|
|
48
ft/pdf/pdf.c
48
ft/pdf/pdf.c
|
@ -1,8 +1,11 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cairo.h>
|
||||
#include <poppler/glib/poppler.h>
|
||||
|
||||
#include "pdf.h"
|
||||
#include "../../zathura.h"
|
||||
|
||||
bool
|
||||
pdf_document_open(zathura_document_t* document)
|
||||
|
@ -238,5 +241,48 @@ pdf_page_form_fields_get(zathura_page_t* page)
|
|||
cairo_surface_t*
|
||||
pdf_page_render(zathura_page_t* page)
|
||||
{
|
||||
return NULL;
|
||||
if(Zathura.document || !page || !page->data || !page->document) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create cairo data */
|
||||
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
|
||||
page->width, page->height);
|
||||
|
||||
if(!surface) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cairo_t* cairo = cairo_create(surface);
|
||||
|
||||
if(!cairo) {
|
||||
cairo_surface_destroy(surface);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch(Zathura.document->rotate) {
|
||||
case 90:
|
||||
cairo_translate(cairo, page->width, 0);
|
||||
break;
|
||||
case 180:
|
||||
cairo_translate(cairo, page->width, page->height);
|
||||
break;
|
||||
case 270:
|
||||
cairo_translate(cairo, 0, page->height);
|
||||
break;
|
||||
default:
|
||||
cairo_translate(cairo, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
cairo_scale(cairo, Zathura.document->scale, Zathura.document->scale);
|
||||
cairo_rotate(cairo, Zathura.document->rotate * G_PI / 180.0);
|
||||
|
||||
/* render */
|
||||
poppler_page_render(page->data, cairo);
|
||||
|
||||
cairo_paint(cairo);
|
||||
cairo_destroy(cairo);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue