const DitherMethod dither_method,ExceptionInfo *exception)
{
#define PosterizeImageTag "Posterize/Image"
-#define PosterizePixel(pixel) (Quantum) (QuantumRange*(MagickRound( \
- QuantumScale*pixel*(levels-1)))/MagickMax((ssize_t) levels-1,1))
+#define PosterizePixel(pixel) ClampToQuantum((MagickRealType) QuantumRange*( \
+ MagickRound(QuantumScale*pixel*(levels-1)))/MagickMax((ssize_t) levels-1,1))
CacheView
*image_view;
static int IntensityCompare(const void *x,const void *y)
{
+ double
+ intensity;
+
PixelInfo
*color_1,
*color_2;
- ssize_t
- intensity;
-
color_1=(PixelInfo *) x;
color_2=(PixelInfo *) y;
- intensity=(ssize_t) (GetPixelInfoIntensity((const Image *) NULL,color_1)-
- GetPixelInfoIntensity((const Image *) NULL,color_2));
+ intensity=GetPixelInfoIntensity((const Image *) NULL,color_1)-
+ GetPixelInfoIntensity((const Image *) NULL,color_2);
+ if (intensity > (double) INT_MAX)
+ intensity=(double) INT_MAX;
+ if (intensity < (double) INT_MIN)
+ intensity=(double) INT_MIN;
return((int) intensity);
}