colorspace-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 colorspace private methods.
00017 */
00018 #ifndef MAGICKCORE_COLORSPACE_PRIVATE_H
00019 #define MAGICKCORE_COLORSPACE_PRIVATE_H
00020 
00021 #include "MagickCore/image.h"
00022 #include "MagickCore/image-private.h"
00023 #include "MagickCore/pixel.h"
00024 #include "MagickCore/pixel-accessor.h"
00025 
00026 #if defined(__cplusplus) || defined(c_plusplus)
00027 extern "C" {
00028 #endif
00029 
00030 static inline void ConvertCMYKToRGB(PixelInfo *pixel)
00031 {
00032   pixel->red=((QuantumRange-(QuantumScale*pixel->red*(QuantumRange-
00033     pixel->black)+pixel->black)));
00034   pixel->green=((QuantumRange-(QuantumScale*pixel->green*(QuantumRange-
00035     pixel->black)+pixel->black)));
00036   pixel->blue=((QuantumRange-(QuantumScale*pixel->blue*(QuantumRange-
00037     pixel->black)+pixel->black)));
00038 }
00039 
00040 static inline void ConvertRGBToCMYK(PixelInfo *pixel)
00041 {
00042   MagickRealType
00043     black,
00044     blue,
00045     cyan,
00046     green,
00047     magenta,
00048     red,
00049     yellow;
00050 
00051   if (pixel->colorspace != sRGBColorspace)
00052     {
00053       red=QuantumScale*pixel->red;
00054       green=QuantumScale*pixel->green;
00055       blue=QuantumScale*pixel->blue;
00056     }
00057   else
00058     {
00059       red=QuantumScale*DecodePixelGamma(pixel->red);
00060       green=QuantumScale*DecodePixelGamma(pixel->green);
00061       blue=QuantumScale*DecodePixelGamma(pixel->blue);
00062     }
00063   if ((fabs((double) red) < MagickEpsilon) &&
00064       (fabs((double) green) < MagickEpsilon) &&
00065       (fabs((double) blue) < MagickEpsilon))
00066     {
00067       pixel->black=(MagickRealType) QuantumRange;
00068       return;
00069     }
00070   cyan=(MagickRealType) (1.0-red);
00071   magenta=(MagickRealType) (1.0-green);
00072   yellow=(MagickRealType) (1.0-blue);
00073   black=cyan;
00074   if (magenta < black)
00075     black=magenta;
00076   if (yellow < black)
00077     black=yellow;
00078   cyan=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(cyan-black));
00079   magenta=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(magenta-black));
00080   yellow=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(yellow-black));
00081   pixel->colorspace=CMYKColorspace;
00082   pixel->red=QuantumRange*cyan;
00083   pixel->green=QuantumRange*magenta;
00084   pixel->blue=QuantumRange*yellow;
00085   pixel->black=QuantumRange*black;
00086 }
00087 
00088 static inline MagickBooleanType IsCMYKColorspace(
00089   const ColorspaceType colorspace)
00090 {
00091   if (colorspace == CMYKColorspace)
00092     return(MagickTrue);
00093   return(MagickFalse);
00094 }
00095 
00096 static inline MagickBooleanType IsGrayColorspace(
00097   const ColorspaceType colorspace)
00098 {
00099   if ((colorspace == LinearGRAYColorspace) || (colorspace == GRAYColorspace))
00100     return(MagickTrue);
00101   return(MagickFalse);
00102 }
00103 
00104 static inline MagickBooleanType IsHueCompatibleColorspace(
00105   const ColorspaceType colorspace)
00106 {
00107   if ((colorspace == HCLColorspace) || (colorspace == HCLpColorspace) ||
00108       (colorspace == HSBColorspace) || (colorspace == HSIColorspace) ||
00109       (colorspace == HSLColorspace) || (colorspace == HSVColorspace))
00110     return(MagickTrue);
00111   return(MagickFalse);
00112 }
00113 
00114 static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
00115 {
00116   if ((colorspace == RGBColorspace) || (colorspace == scRGBColorspace) ||
00117       (colorspace == LinearGRAYColorspace))
00118     return(MagickTrue);
00119   return(MagickFalse);
00120 }
00121 
00122 static inline MagickBooleanType IssRGBColorspace(
00123   const ColorspaceType colorspace)
00124 {
00125   if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace))
00126     return(MagickTrue);
00127   return(MagickFalse);
00128 }
00129 
00130 static inline MagickBooleanType IssRGBCompatibleColorspace(
00131   const ColorspaceType colorspace)
00132 {
00133   if ((colorspace == sRGBColorspace) || (colorspace == RGBColorspace) ||
00134       (colorspace == scRGBColorspace) || (colorspace == TransparentColorspace) ||
00135       (colorspace == GRAYColorspace) || (colorspace == LinearGRAYColorspace))
00136     return(MagickTrue);
00137   return(MagickFalse);
00138 }
00139 
00140 #if defined(__cplusplus) || defined(c_plusplus)
00141 }
00142 #endif
00143 
00144 #endif

Generated on 7 Apr 2020 for MagickCore by  doxygen 1.6.1