From: cristy Date: Thu, 23 Aug 2012 13:58:32 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~5071 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b016eaf064ae0ce5800366145bbc52a722395ed;p=imagemagick --- diff --git a/coders/tiff.c b/coders/tiff.c index 54828f388..73a88fb18 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -1301,25 +1301,33 @@ static Image *ReadTIFFImage(const ImageInfo *image_info, /* Initialize colormap. */ + red_colormap=(uint16 *) NULL; + green_colormap=(uint16 *) NULL; + blue_colormap=(uint16 *) NULL; (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap, &green_colormap,&blue_colormap); - range=255; /* might be old style 8-bit colormap */ - for (i=0; i < (ssize_t) image->colors; i++) - if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) || - (blue_colormap[i] >= 256)) + if ((red_colormap != (uint16 *) NULL) && + (green_colormap != (uint16 *) NULL) && + (blue_colormap != (uint16 *) NULL)) + { + range=255; /* might be old style 8-bit colormap */ + for (i=0; i < (ssize_t) image->colors; i++) + if ((red_colormap[i] >= 256) || (green_colormap[i] >= 256) || + (blue_colormap[i] >= 256)) + { + range=65535; + break; + } + for (i=0; i < (ssize_t) image->colors; i++) { - range=65535; - break; + image->colormap[i].red=ClampToQuantum(((double) + QuantumRange*red_colormap[i])/range); + image->colormap[i].green=ClampToQuantum(((double) + QuantumRange*green_colormap[i])/range); + image->colormap[i].blue=ClampToQuantum(((double) + QuantumRange*blue_colormap[i])/range); } - for (i=0; i < (ssize_t) image->colors; i++) - { - image->colormap[i].red=ClampToQuantum(((double) QuantumRange* - red_colormap[i])/range); - image->colormap[i].green=ClampToQuantum(((double) QuantumRange* - green_colormap[i])/range); - image->colormap[i].blue=ClampToQuantum(((double) QuantumRange* - blue_colormap[i])/range); - } + } } quantum_type=IndexQuantum; pad=(size_t) MagickMax((size_t) samples_per_pixel-1,0);