aboutsummaryrefslogtreecommitdiff
path: root/rdgif.c
diff options
context:
space:
mode:
authorThomas G. Lane <tgl@netcom.com>1994-12-07 00:00:00 +0000
committerDRC <information@libjpeg-turbo.org>2015-07-29 15:29:17 -0500
commit9ba2f5ed3649fb6de83d3c16e4dba1443aaca983 (patch)
treecfd9b7b2ec501c4243645b4a1d1e3448b3f477a7 /rdgif.c
parent36a4ccccd33f5cc9df62949554af87129ced7f84 (diff)
downloadlibjpeg-turbo-9ba2f5ed3649fb6de83d3c16e4dba1443aaca983.tar.gz
The Independent JPEG Group's JPEG software v5a
Diffstat (limited to 'rdgif.c')
-rw-r--r--rdgif.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/rdgif.c b/rdgif.c
index b8866024..c4bc9ef7 100644
--- a/rdgif.c
+++ b/rdgif.c
@@ -352,9 +352,14 @@ ReadColorMap (gif_source_ptr sinfo, int cmaplen, JSAMPARRAY cmap)
int i;
for (i = 0; i < cmaplen; i++) {
- cmap[CM_RED][i] = (JSAMPLE) ReadByte(sinfo);
- cmap[CM_GREEN][i] = (JSAMPLE) ReadByte(sinfo);
- cmap[CM_BLUE][i] = (JSAMPLE) ReadByte(sinfo);
+#if BITS_IN_JSAMPLE == 8
+#define UPSCALE(x) (x)
+#else
+#define UPSCALE(x) ((x) << (BITS_IN_JSAMPLE-8))
+#endif
+ cmap[CM_RED][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo));
+ cmap[CM_GREEN][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo));
+ cmap[CM_BLUE][i] = (JSAMPLE) UPSCALE(ReadByte(sinfo));
}
}
@@ -508,7 +513,7 @@ start_input_gif (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* Return info about the image. */
cinfo->in_color_space = JCS_RGB;
cinfo->input_components = NUMCOLORS;
- cinfo->data_precision = 8;
+ cinfo->data_precision = BITS_IN_JSAMPLE; /* we always rescale data to this */
cinfo->image_width = width;
cinfo->image_height = height;