From 45307629cef494a2b35329f16b7a3d09f7da222e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Wed, 7 May 2014 15:09:22 +0200 Subject: Correctly round PNG image resolution Currently, png_read_phys always rounds the resolution down. Many images have a resolution just slightly shy of 96 DPI and are thus rendered too large when they're resized from 95 to match the required 96 for output. --- source/fitz/load-png.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/fitz/load-png.c b/source/fitz/load-png.c index 984dbed2..d897b5be 100644 --- a/source/fitz/load-png.c +++ b/source/fitz/load-png.c @@ -360,8 +360,8 @@ png_read_phys(struct info *info, unsigned char *p, unsigned int size) fz_throw(info->ctx, FZ_ERROR_GENERIC, "pHYs chunk is the wrong size"); if (p[8] == 1) { - info->xres = getuint(p) * 254 / 10000; - info->yres = getuint(p + 4) * 254 / 10000; + info->xres = (getuint(p) * 254 + 5000) / 10000; + info->yres = (getuint(p + 4) * 254 + 5000) / 10000; } } -- cgit v1.2.3