00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MAGICKCORE_COLORMAP_PRIVATE_H
00019 #define MAGICKCORE_COLORMAP_PRIVATE_H
00020
00021 #include "magick/image.h"
00022 #include "magick/color.h"
00023 #include "magick/exception-private.h"
00024
00025 #if defined(__cplusplus) || defined(c_plusplus)
00026 extern "C" {
00027 #endif
00028
00029 static inline IndexPacket ConstrainColormapIndex(Image *image,
00030 const ssize_t index)
00031 {
00032 if ((index < 0) || (index >= (ssize_t) image->colors))
00033 {
00034 if (image->exception.severity != CorruptImageError)
00035 (void) ThrowMagickException(&image->exception,GetMagickModule(),
00036 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
00037 return((IndexPacket) 0);
00038 }
00039 return((IndexPacket) index);
00040 }
00041
00042 static inline MagickBooleanType IsValidColormapIndex(Image *image,
00043 const ssize_t index,IndexPacket *target,ExceptionInfo *exception)
00044 {
00045 if ((index < 0) || (index >= (ssize_t) image->colors))
00046 {
00047 if (image->exception.severity != CorruptImageError)
00048 (void) ThrowMagickException(exception,GetMagickModule(),
00049 CorruptImageError,"InvalidColormapIndex","`%s'",image->filename);
00050 *target=(IndexPacket) 0;
00051 return(MagickFalse);
00052 }
00053 *target=(IndexPacket) index;
00054 return(MagickTrue);
00055 }
00056
00057 #if defined(__cplusplus) || defined(c_plusplus)
00058 }
00059 #endif
00060
00061 #endif