From: dirk Date: Mon, 16 Feb 2015 20:38:17 +0000 (+0000) Subject: Fixed reading value at incorrect index. X-Git-Tag: 7.0.1-0~1284 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=179252377b6aa1f9031a23d693e0760826a327b6;p=imagemagick Fixed reading value at incorrect index. --- diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index c7cef10bc..82c9d9686 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -1048,8 +1048,8 @@ MagickExport MagickBooleanType ContrastStretchImage(Image *image, white=(double *) AcquireQuantumMemory(MaxPixelChannels,sizeof(*white)); histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels* sizeof(*histogram)); - stretch_map=(double *) AcquireQuantumMemory(MaxMap+1UL,MaxPixelChannels* - sizeof(*stretch_map)); + stretch_map=(double *) AcquireQuantumMemory(MaxMap+1UL, + GetPixelChannels(image)*sizeof(*stretch_map)); if ((black == (double *) NULL) || (white == (double *) NULL) || (histogram == (double *) NULL) || (stretch_map == (double *) NULL)) { @@ -1176,25 +1176,25 @@ MagickExport MagickBooleanType ContrastStretchImage(Image *image, { if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) { - i=GetPixelChannelChannel(image,RedPixelChannel); + i=GetPixelChannelOffset(image,RedPixelChannel); image->colormap[j].red=stretch_map[GetPixelChannels(image)* ScaleQuantumToMap(ClampToQuantum(image->colormap[j].red))+i]; } if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) { - i=GetPixelChannelChannel(image,GreenPixelChannel); + i=GetPixelChannelOffset(image,GreenPixelChannel); image->colormap[j].green=stretch_map[GetPixelChannels(image)* ScaleQuantumToMap(ClampToQuantum(image->colormap[j].green))+i]; } if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) { - i=GetPixelChannelChannel(image,BluePixelChannel); + i=GetPixelChannelOffset(image,BluePixelChannel); image->colormap[j].blue=stretch_map[GetPixelChannels(image)* ScaleQuantumToMap(ClampToQuantum(image->colormap[j].blue))+i]; } if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) { - i=GetPixelChannelChannel(image,AlphaPixelChannel); + i=GetPixelChannelOffset(image,AlphaPixelChannel); image->colormap[j].alpha=stretch_map[GetPixelChannels(image)* ScaleQuantumToMap(ClampToQuantum(image->colormap[j].alpha))+i]; }