summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-02-09 12:22:27 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-02-09 12:22:27 +0000
commite463a645a3188c26882db9df97465d052d46217b (patch)
tree472082ea358e810b4c847365f396ad1a57c48349
parent950ab167fc3a27a8f5e68eed1de620aac513ab53 (diff)
xetexdir/image/jpegimage.c: Better rounding
git-svn-id: svn://tug.org/texlive/trunk@36242 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/texk/web2c/xetexdir/image/jpegimage.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Build/source/texk/web2c/xetexdir/image/jpegimage.c b/Build/source/texk/web2c/xetexdir/image/jpegimage.c
index 25f7c90a910..fb72b1a8630 100644
--- a/Build/source/texk/web2c/xetexdir/image/jpegimage.c
+++ b/Build/source/texk/web2c/xetexdir/image/jpegimage.c
@@ -83,6 +83,7 @@
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "kpathsea/lib.h" /* for xmalloc/xrealloc prototypes */
@@ -431,6 +432,7 @@ JPEG_scan_file (struct JPEG_info *j_info, FILE *fp)
int found_SOFn, count;
char app_sig[128];
double xdensity, ydensity;
+ double image_w, image_h;
JPEG_info_init(j_info);
@@ -528,11 +530,16 @@ JPEG_scan_file (struct JPEG_info *j_info, FILE *fp)
jpeg_get_density (j_info, &xdensity, &ydensity);
- j_info->width = (unsigned short)(j_info->width * xdensity);
- j_info->height = (unsigned short)(j_info->height * ydensity);
+ image_w = floor((j_info->width * xdensity) + 0.5);
+ image_h = floor((j_info->height * ydensity) + 0.5);
+
+ j_info->width = (unsigned short)(image_w);
+ j_info->height = (unsigned short)(image_h);
+
/*
Now, j_info->width and j_info->height are correct width and
height in bp unit
*/
+
return (found_SOFn ? 0 : -1);
}