2 Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
8 http://www.imagemagick.org/script/license.php
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 MagickCore image pixel private methods.
18 #ifndef _MAGICKCORE_PIXEL_PRIVATE_H
19 #define _MAGICKCORE_PIXEL_PRIVATE_H
21 #if defined(__cplusplus) || defined(c_plusplus)
25 #include <magick/exception-private.h>
26 #include <magick/image.h>
27 #include <magick/color.h>
28 #include <magick/image-private.h>
29 #include <magick/quantum-private.h>
31 static inline MagickPixelPacket *CloneMagickPixelPacket(
32 const MagickPixelPacket *pixel)
37 clone_pixel=(MagickPixelPacket *) AcquireAlignedMemory(1,
38 sizeof(*clone_pixel));
39 if (clone_pixel == (MagickPixelPacket *) NULL)
40 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
41 *clone_pixel=(*pixel);
45 static inline MagickBooleanType IsGrayPixel(const PixelPacket *pixel)
47 #if !defined(MAGICKCORE_HDRI_SUPPORT)
48 if ((pixel->red == pixel->green) && (pixel->green == pixel->blue))
51 if ((fabs(pixel->red-pixel->green) <= MagickEpsilon) &&
52 (fabs(pixel->green-pixel->blue) <= MagickEpsilon))
58 static inline MagickBooleanType IsMonochromePixel(const PixelPacket *pixel)
60 #if !defined(MAGICKCORE_HDRI_SUPPORT)
61 if (((pixel->red == 0) || (pixel->red == (Quantum) QuantumRange)) &&
62 (pixel->red == pixel->green) && (pixel->green == pixel->blue))
65 if (((fabs(pixel->red) <= MagickEpsilon) ||
66 (fabs(pixel->red-QuantumRange) <= MagickEpsilon)) &&
67 (fabs(pixel->red-pixel->green) <= MagickEpsilon) &&
68 (fabs(pixel->green-pixel->blue) <= MagickEpsilon))
74 static inline void SetMagickPixelPacket(const Image *image,
75 const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel)
77 pixel->red=(MagickRealType) color->red;
78 pixel->green=(MagickRealType) color->green;
79 pixel->blue=(MagickRealType) color->blue;
80 pixel->opacity=(MagickRealType) color->opacity;
81 if (((image->colorspace == CMYKColorspace) ||
82 (image->storage_class == PseudoClass)) &&
83 (index != (const IndexPacket *) NULL))
84 pixel->index=(MagickRealType) *index;
87 /* This function is obsoleted by MorphologyApply() -- Anthony Thyssen */
88 static inline void SetMagickPixelPacketBias(const Image *image,
89 MagickPixelPacket *pixel)
91 pixel->red=image->bias;
92 pixel->green=image->bias;
93 pixel->blue=image->bias;
94 pixel->opacity=image->bias;
95 pixel->index=image->bias;
98 static inline void SetPixelPacket(const Image *image,
99 const MagickPixelPacket *pixel,PixelPacket *color,IndexPacket *index)
101 color->red=ClampToQuantum(pixel->red);
102 color->green=ClampToQuantum(pixel->green);
103 color->blue=ClampToQuantum(pixel->blue);
104 color->opacity=ClampToQuantum(pixel->opacity);
105 if (((image->colorspace == CMYKColorspace) ||
106 (image->storage_class == PseudoClass)) &&
107 (index != (const IndexPacket *) NULL))
108 *index=ClampToQuantum(pixel->index);
111 #if defined(__cplusplus) || defined(c_plusplus)