return((ssize_t) index);
}
-static inline MagickBooleanType IsValidColormapIndex(Image *image,
+static inline void ValidateColormapValue(Image *image,
const ssize_t index,Quantum *target,ExceptionInfo *exception)
{
if ((index < 0) || (index >= (ssize_t) image->colors))
(void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
"InvalidColormapIndex","`%s'",image->filename);
*target=(Quantum) 0;
- return(MagickFalse);
}
- *target=(Quantum) index;
- return(MagickTrue);
+ else
+ *target=(Quantum) index;
}
#if defined(__cplusplus) || defined(c_plusplus)
break;
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- (void) IsValidColormapIndex(image,(*p >> 4) & 0x0f,&index,
- exception);
+ ValidateColormapValue(image,(*p >> 4) & 0x0f,&index,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
- (void) IsValidColormapIndex(image,*p & 0x0f,&index,exception);
+ ValidateColormapValue(image,*p & 0x0f,&index,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
p++;
}
if ((image->columns % 2) != 0)
{
- IsValidColormapIndex(image,(*p >> 4) & 0xf,&index,exception);
+ ValidateColormapValue(image,(*p >> 4) & 0xf,&index,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
p++;
break;
for (x=(ssize_t) image->columns; x != 0; --x)
{
- (void) IsValidColormapIndex(image,*p++,&index,exception);
+ ValidateColormapValue(image,*p++,&index,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
}
if (number_colormaps == 1)
for (i=0; i < (ssize_t) number_pixels; i++)
{
- if (IsValidColormapIndex(image,*p & mask,&index,exception) ==
- MagickFalse)
- break;
+ ValidateColormapValue(image,*p & mask,&index,exception);
*p=colormap[(ssize_t) index];
p++;
}
for (i=0; i < (ssize_t) number_pixels; i++)
for (x=0; x < (ssize_t) number_planes; x++)
{
- if (IsValidColormapIndex(image,(size_t) (x*map_length+
- (*p & mask)),&index,exception) == MagickFalse)
- break;
+ ValidateColormapValue(image,(size_t) (x*map_length+
+ (*p & mask)),&index,exception);
*p=colormap[(ssize_t) index];
p++;
}
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
- exception) == MagickFalse)
- break;
+ ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
SetPixelRed(image,ClampToQuantum(image->colormap[(ssize_t)
index].red),q);
- if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
- exception) == MagickFalse)
- break;
+ ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
SetPixelGreen(image,ClampToQuantum(image->colormap[(ssize_t)
index].green),q);
- if (IsValidColormapIndex(image,(ssize_t) *p++,&index,
- exception) == MagickFalse)
- break;
+ ValidateColormapValue(image,(ssize_t) *p++,&index,exception);
SetPixelBlue(image,ClampToQuantum(image->colormap[(ssize_t)
index].blue),q);
SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);