2 Copyright 1999-2016 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 colorspace private methods.
18 #ifndef MAGICKCORE_COLORSPACE_PRIVATE_H
19 #define MAGICKCORE_COLORSPACE_PRIVATE_H
21 #include "MagickCore/image.h"
22 #include "MagickCore/image-private.h"
23 #include "MagickCore/pixel.h"
24 #include "MagickCore/pixel-accessor.h"
26 #if defined(__cplusplus) || defined(c_plusplus)
30 static inline void ConvertCMYKToRGB(PixelInfo *pixel)
32 pixel->red=((QuantumRange-(QuantumScale*pixel->red*(QuantumRange-
33 pixel->black)+pixel->black)));
34 pixel->green=((QuantumRange-(QuantumScale*pixel->green*(QuantumRange-
35 pixel->black)+pixel->black)));
36 pixel->blue=((QuantumRange-(QuantumScale*pixel->blue*(QuantumRange-
37 pixel->black)+pixel->black)));
40 static inline void ConvertRGBToCMYK(PixelInfo *pixel)
51 if (pixel->colorspace != sRGBColorspace)
53 red=QuantumScale*pixel->red;
54 green=QuantumScale*pixel->green;
55 blue=QuantumScale*pixel->blue;
59 red=QuantumScale*DecodePixelGamma(pixel->red);
60 green=QuantumScale*DecodePixelGamma(pixel->green);
61 blue=QuantumScale*DecodePixelGamma(pixel->blue);
63 if ((fabs((double) red) < MagickEpsilon) &&
64 (fabs((double) green) < MagickEpsilon) &&
65 (fabs((double) blue) < MagickEpsilon))
67 pixel->black=(MagickRealType) QuantumRange;
70 cyan=(MagickRealType) (1.0-red);
71 magenta=(MagickRealType) (1.0-green);
72 yellow=(MagickRealType) (1.0-blue);
78 cyan=(MagickRealType) ((cyan-black)/(1.0-black));
79 magenta=(MagickRealType) ((magenta-black)/(1.0-black));
80 yellow=(MagickRealType) ((yellow-black)/(1.0-black));
81 pixel->colorspace=CMYKColorspace;
82 pixel->red=QuantumRange*cyan;
83 pixel->green=QuantumRange*magenta;
84 pixel->blue=QuantumRange*yellow;
85 pixel->black=QuantumRange*black;
88 static inline MagickBooleanType IsCMYKColorspace(
89 const ColorspaceType colorspace)
91 if (colorspace == CMYKColorspace)
96 static inline MagickBooleanType IsGrayColorspace(
97 const ColorspaceType colorspace)
99 if (colorspace == GRAYColorspace)
104 static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
106 if ((colorspace == RGBColorspace) || (colorspace == scRGBColorspace))
111 static inline MagickBooleanType IssRGBColorspace(
112 const ColorspaceType colorspace)
114 if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace))
119 static inline MagickBooleanType IssRGBCompatibleColorspace(
120 const ColorspaceType colorspace)
122 if ((colorspace == sRGBColorspace) || (colorspace == RGBColorspace) ||
123 (colorspace == scRGBColorspace) ||
124 (IsGrayColorspace(colorspace) != MagickFalse))
129 #if defined(__cplusplus) || defined(c_plusplus)