pixel-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 pixel private methods.
00017 */
00018 #ifndef MAGICKCORE_PIXEL_PRIVATE_H
00019 #define MAGICKCORE_PIXEL_PRIVATE_H
00020 
00021 #include "magick/image.h"
00022 #include "magick/color.h"
00023 #include "magick/image-private.h"
00024 #include "magick/memory_.h"
00025 #include "magick/pixel-accessor.h"
00026 #include "magick/quantum-private.h"
00027 
00028 #if defined(__cplusplus) || defined(c_plusplus)
00029 extern "C" {
00030 #endif
00031 
00032 static inline MagickBooleanType IsGrayPixel(const PixelPacket *pixel)
00033 {
00034 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00035   if ((GetPixelRed(pixel) == GetPixelGreen(pixel)) && 
00036       (GetPixelGreen(pixel) == GetPixelBlue(pixel)))
00037     return(MagickTrue);
00038 #else
00039   {
00040     double
00041       alpha,
00042       beta;
00043 
00044     alpha=GetPixelRed(pixel)-(double) GetPixelGreen(pixel);
00045     beta=GetPixelGreen(pixel)-(double) GetPixelBlue(pixel);
00046     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
00047       return(MagickTrue);
00048   }
00049 #endif
00050   return(MagickFalse);
00051 }
00052 
00053 static inline MagickBooleanType IsMonochromePixel(const PixelPacket *pixel)
00054 {
00055 #if !defined(MAGICKCORE_HDRI_SUPPORT)
00056   if (((GetPixelRed(pixel) == 0) ||
00057        (GetPixelRed(pixel) == QuantumRange)) &&
00058       (GetPixelRed(pixel) == GetPixelGreen(pixel)) &&
00059       (GetPixelGreen(pixel) == GetPixelBlue(pixel)))
00060     return(MagickTrue);
00061 #else
00062   {
00063     double
00064       alpha,
00065       beta;
00066 
00067     alpha=GetPixelRed(pixel)-(double) GetPixelGreen(pixel);
00068     beta=GetPixelGreen(pixel)-(double) GetPixelBlue(pixel);
00069     if (((fabs((double) GetPixelRed(pixel)) <= MagickEpsilon) ||
00070          (fabs((double) GetPixelRed(pixel)-QuantumRange) <= MagickEpsilon)) &&
00071         (fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
00072       return(MagickTrue);
00073     }
00074 #endif
00075   return(MagickFalse);
00076 }
00077 
00078 static inline void SetMagickPixelPacket(const Image *image,
00079   const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel)
00080 {
00081   pixel->red=(MagickRealType) GetPixelRed(color);
00082   pixel->green=(MagickRealType) GetPixelGreen(color);
00083   pixel->blue=(MagickRealType) GetPixelBlue(color);
00084   pixel->opacity=(MagickRealType) GetPixelOpacity(color);
00085   if ((image->colorspace == CMYKColorspace) &&
00086       (index != (const IndexPacket *) NULL))
00087     pixel->index=(MagickRealType) GetPixelIndex(index);
00088 }
00089 
00090 static inline void SetMagickPixelPacketBias(const Image *image,
00091   MagickPixelPacket *pixel)
00092 {
00093   /*
00094     Obsoleted by MorphologyApply().
00095   */
00096   pixel->red=image->bias;
00097   pixel->green=image->bias;
00098   pixel->blue=image->bias;
00099   pixel->opacity=image->bias;
00100   pixel->index=image->bias;
00101 }
00102 
00103 static inline void SetPixelPacket(const Image *image,
00104   const MagickPixelPacket *pixel,PixelPacket *color,IndexPacket *index)
00105 {
00106   SetPixelRed(color,ClampToQuantum(pixel->red));
00107   SetPixelGreen(color,ClampToQuantum(pixel->green));
00108   SetPixelBlue(color,ClampToQuantum(pixel->blue));
00109   SetPixelOpacity(color,ClampToQuantum(pixel->opacity));
00110   if ((image->colorspace == CMYKColorspace) ||
00111       (image->storage_class == PseudoClass))
00112     SetPixelIndex(index,ClampToQuantum(pixel->index));
00113 }
00114 
00115 #if defined(__cplusplus) || defined(c_plusplus)
00116 }
00117 #endif
00118 
00119 #endif

Generated on 17 Mar 2020 for MagickCore by  doxygen 1.6.1