18 #ifndef MAGICKCORE_COLORMAP_PRIVATE_H
19 #define MAGICKCORE_COLORMAP_PRIVATE_H
21 #include "magick/image.h"
22 #include "magick/color.h"
23 #include "magick/exception-private.h"
25 #if defined(__cplusplus) || defined(c_plusplus)
29 static inline IndexPacket ConstrainColormapIndex(
Image *image,
32 if ((index < 0) || (index >= (ssize_t) image->colors))
34 if (image->exception.severity != CorruptImageError)
35 (void) ThrowMagickException(&image->exception,GetMagickModule(),
36 CorruptImageError,
"InvalidColormapIndex",
"`%s'",image->filename);
37 return((IndexPacket) 0);
39 return((IndexPacket) index);
42 static inline MagickBooleanType IsValidColormapIndex(
Image *image,
43 const ssize_t index,IndexPacket *target,
ExceptionInfo *exception)
45 if ((index < 0) || (index >= (ssize_t) image->colors))
47 if (image->exception.severity != CorruptImageError)
48 (void) ThrowMagickException(exception,GetMagickModule(),
49 CorruptImageError,
"InvalidColormapIndex",
"`%s'",image->filename);
50 *target=(IndexPacket) 0;
53 *target=(IndexPacket) index;
57 #if defined(__cplusplus) || defined(c_plusplus)