diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2014-04-22 14:32:47 +0100 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2014-04-24 10:05:43 +0100 |
commit | 2eabdfb49215ad955462a2a6441a8032bc68ab1f (patch) | |
tree | 2c2cbe38302a9e13b672d09f4d4f79c621fe95b7 /platform/ios/Classes | |
parent | e7c259cafdf934ee98c208abeaed8e0ca52190ac (diff) | |
download | mupdf-2eabdfb49215ad955462a2a6441a8032bc68ab1f.tar.xz |
iOS: fix AirPrint quality to 300 dpi
Diffstat (limited to 'platform/ios/Classes')
-rw-r--r-- | platform/ios/Classes/MuPrintPageRenderer.m | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/platform/ios/Classes/MuPrintPageRenderer.m b/platform/ios/Classes/MuPrintPageRenderer.m index 919145fd..1b6d6769 100644 --- a/platform/ios/Classes/MuPrintPageRenderer.m +++ b/platform/ios/Classes/MuPrintPageRenderer.m @@ -131,6 +131,8 @@ static void renderPage(fz_document *doc, fz_page *page, fz_pixmap *pix, fz_matri CGDataProviderRef dataref = NULL; CGImageRef img = NULL; CGContextRef cgctx = UIGraphicsGetCurrentContext(); + float dpi = 300.0; + float ppi = 72.0; if (!cgctx) return; @@ -143,10 +145,12 @@ static void renderPage(fz_document *doc, fz_page *page, fz_pixmap *pix, fz_matri goto exit; CGSize scale = fitPageToScreen(pageSize, paperSize); - pageSize.width = roundf(pageSize.width * scale.width); - pageSize.height = roundf(pageSize.height *scale.height); + pageSize.width *= scale.width; + pageSize.height *= scale.height; - pix = createPixMap(pageSize); + CGSize pageSizePix = {roundf(pageSize.width * dpi / ppi), roundf(pageSize.height * dpi /ppi)}; + + pix = createPixMap(pageSizePix); if (!pix) goto exit; @@ -159,7 +163,7 @@ static void renderPage(fz_document *doc, fz_page *page, fz_pixmap *pix, fz_matri goto exit; fz_matrix ctm; - fz_scale(&ctm, scale.width, -scale.height); + fz_scale(&ctm, scale.width * dpi / ppi, -scale.height * dpi / ppi); fz_pre_translate(&ctm, 0, -pageSize.height); renderPage(docRef->doc, page, pix, &ctm); |