summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/xetexdir/image/jpegimage.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/xetexdir/image/jpegimage.c')
-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);
}