From ecef579ce07d76ff6e0bee99bf8461e7674a8f68 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 26 Dec 2010 00:28:53 +0100 Subject: [PATCH] Get/Free djvu page --- ft/djvu/djvu.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ft/djvu/djvu.c b/ft/djvu/djvu.c index c66cc5d..b6c3a61 100644 --- a/ft/djvu/djvu.c +++ b/ft/djvu/djvu.c @@ -33,7 +33,7 @@ djvu_document_open(zathura_document_t* document) djvu_document->format = NULL; /* setup format */ - djvu_document->format = ddjvu_format_create (DDJVU_FORMAT_RGBMASK32, 0, NULL); + djvu_document->format = ddjvu_format_create(DDJVU_FORMAT_RGB24, 0, NULL); if(!djvu_document->format) { goto error_free; @@ -134,7 +134,25 @@ djvu_page_get(zathura_document_t* document, unsigned int page) return NULL; } - return NULL; + djvu_document_t* djvu_document = (djvu_document_t*) document->data; + zathura_page_t* document_page = malloc(sizeof(zathura_page_t)); + + if(!document_page) { + return NULL; + } + + document_page->document = document; + document_page->data = ddjvu_page_create_by_pageno(djvu_document->document, page);; + + if(!document_page->data) { + free(document_page); + return NULL; + } + + document_page->width = ddjvu_page_get_width(document_page->data); + document_page->height = ddjvu_page_get_width(document_page->data); + + return document_page; } bool @@ -144,6 +162,9 @@ djvu_page_free(zathura_page_t* page) return false; } + ddjvu_page_release(page->data); + free(page); + return true; }