00001 /* 00002 Copyright 1999-2009 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. 00006 obtain a copy of the License at 00007 00008 http://www.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 pixel private methods. 00017 */ 00018 #ifndef _MAGICKCORE_PIXEL_PRIVATE_H 00019 #define _MAGICKCORE_PIXEL_PRIVATE_H 00020 00021 #if defined(__cplusplus) || defined(c_plusplus) 00022 extern "C" { 00023 #endif 00024 00025 #include <magick/exception-private.h> 00026 #include <magick/image.h> 00027 #include <magick/color.h> 00028 #include <magick/image-private.h> 00029 #include <magick/quantum-private.h> 00030 00031 static inline MagickPixelPacket *CloneMagickPixelPacket( 00032 const MagickPixelPacket *pixel) 00033 { 00034 MagickPixelPacket 00035 *clone_pixel; 00036 00037 clone_pixel=(MagickPixelPacket *) AcquireMagickMemory(sizeof(*clone_pixel)); 00038 if (clone_pixel == (MagickPixelPacket *) NULL) 00039 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); 00040 *clone_pixel=(*pixel); 00041 return(clone_pixel); 00042 } 00043 00044 static inline MagickBooleanType IsGrayPixel(const PixelPacket *pixel) 00045 { 00046 #if !defined(MAGICKCORE_HDRI_SUPPORT) 00047 if ((pixel->red == pixel->green) && (pixel->green == pixel->blue)) 00048 return(MagickTrue); 00049 #else 00050 if ((fabs(pixel->red-pixel->green) <= MagickEpsilon) && 00051 (fabs(pixel->green-pixel->blue) <= MagickEpsilon)) 00052 return(MagickTrue); 00053 #endif 00054 return(MagickFalse); 00055 } 00056 00057 static inline MagickBooleanType IsMonochromePixel(const PixelPacket *pixel) 00058 { 00059 #if !defined(MAGICKCORE_HDRI_SUPPORT) 00060 if (((pixel->red == 0) || (pixel->red == (Quantum) QuantumRange)) && 00061 (pixel->red == pixel->green) && (pixel->green == pixel->blue)) 00062 return(MagickTrue); 00063 #else 00064 if (((fabs(pixel->red) <= MagickEpsilon) || 00065 (fabs(pixel->red-QuantumRange) <= MagickEpsilon)) && 00066 (fabs(pixel->red-pixel->green) <= MagickEpsilon) && 00067 (fabs(pixel->green-pixel->blue) <= MagickEpsilon)) 00068 return(MagickTrue); 00069 #endif 00070 return(MagickFalse); 00071 } 00072 00073 static inline void SetMagickPixelPacket(const Image *image, 00074 const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel) 00075 { 00076 pixel->red=(MagickRealType) color->red; 00077 pixel->green=(MagickRealType) color->green; 00078 pixel->blue=(MagickRealType) color->blue; 00079 pixel->opacity=(MagickRealType) color->opacity; 00080 if (((image->colorspace == CMYKColorspace) || 00081 (image->storage_class == PseudoClass)) && 00082 (index != (const IndexPacket *) NULL)) 00083 pixel->index=(MagickRealType) *index; 00084 } 00085 00086 static inline void SetMagickPixelPacketBias(const Image *image, 00087 MagickPixelPacket *pixel) 00088 { 00089 pixel->red=image->bias; 00090 pixel->green=image->bias; 00091 pixel->blue=image->bias; 00092 pixel->opacity=image->bias; 00093 pixel->index=image->bias; 00094 } 00095 00096 static inline void SetPixelPacket(const Image *image, 00097 const MagickPixelPacket *pixel,PixelPacket *color,IndexPacket *index) 00098 { 00099 color->red=RoundToQuantum(pixel->red); 00100 color->green=RoundToQuantum(pixel->green); 00101 color->blue=RoundToQuantum(pixel->blue); 00102 color->opacity=RoundToQuantum(pixel->opacity); 00103 if (((image->colorspace == CMYKColorspace) || 00104 (image->storage_class == PseudoClass)) && 00105 (index != (const IndexPacket *) NULL)) 00106 *index=RoundToQuantum(pixel->index); 00107 } 00108 00109 #if defined(__cplusplus) || defined(c_plusplus) 00110 } 00111 #endif 00112 00113 #endif
1.6.1