colormap-private.h

Go to the documentation of this file.
00001 /*
00002   Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization
00003   dedicated to making software imaging solutions freely available.
00004 
00005   You may not use this file except in compliance with the License.  You may
00006   obtain a copy of the License at
00007 
00008     https://imagemagick.org/script/license.php
00009 
00010   Unless required by applicable law or agreed to in writing, software
00011   distributed under the License is distributed on an "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013   See the License for the specific language governing permissions and
00014   limitations under the License.
00015 
00016   MagickCore image colormap methods.
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

Generated on 6 Jan 2020 for MagickCore by  doxygen 1.6.1