MagickCore  6.8.9
colorspace-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License.
6  obtain a copy of the License at
7 
8  http://www.imagemagick.org/script/license.php
9 
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.
15 
16  MagickCore image colorspace private methods.
17 */
18 #ifndef _MAGICKCORE_COLORSPACE_PRIVATE_H
19 #define _MAGICKCORE_COLORSPACE_PRIVATE_H
20 
21 #include "magick/image.h"
22 #include "magick/image-private.h"
23 #include "magick/pixel.h"
24 #include "magick/pixel-accessor.h"
25 #include "magick/pixel-private.h"
26 
27 #if defined(__cplusplus) || defined(c_plusplus)
28 extern "C" {
29 #endif
30 
31 static inline void ConvertRGBToCMYK(MagickPixelPacket *pixel)
32 {
34  black,
35  blue,
36  cyan,
37  green,
38  magenta,
39  red,
40  yellow;
41 
42  if (pixel->colorspace != sRGBColorspace)
43  {
44  red=QuantumScale*pixel->red;
45  green=QuantumScale*pixel->green;
46  blue=QuantumScale*pixel->blue;
47  }
48  else
49  {
50  red=DecodePixelGamma(pixel->red);
51  green=DecodePixelGamma(pixel->green);
52  blue=DecodePixelGamma(pixel->blue);
53  }
54  if ((fabs(red) < MagickEpsilon) && (fabs(green) < MagickEpsilon) &&
55  (fabs(blue) < MagickEpsilon))
56  {
58  return;
59  }
60  cyan=(MagickRealType) (1.0-red);
61  magenta=(MagickRealType) (1.0-green);
62  yellow=(MagickRealType) (1.0-blue);
63  black=cyan;
64  if (magenta < black)
65  black=magenta;
66  if (yellow < black)
67  black=yellow;
68  cyan=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(cyan-black));
69  magenta=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(magenta-black));
70  yellow=(MagickRealType) (PerceptibleReciprocal(1.0-black)*(yellow-black));
72  pixel->red=QuantumRange*cyan;
73  pixel->green=QuantumRange*magenta;
74  pixel->blue=QuantumRange*yellow;
75  pixel->index=QuantumRange*black;
76 }
77 
79  const ColorspaceType colorspace)
80 {
81  if (colorspace == CMYKColorspace)
82  return(MagickTrue);
83  return(MagickFalse);
84 }
85 
87  const ColorspaceType colorspace)
88 {
89  if ((colorspace == GRAYColorspace) || (colorspace == Rec601LumaColorspace) ||
90  (colorspace == Rec709LumaColorspace))
91  return(MagickTrue);
92  return(MagickFalse);
93 }
94 
95 static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
96 {
97  if ((colorspace == RGBColorspace) || (colorspace == scRGBColorspace))
98  return(MagickTrue);
99  return(MagickFalse);
100 }
101 
103  const ColorspaceType colorspace)
104 {
105  if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace))
106  return(MagickTrue);
107  return(MagickFalse);
108 }
109 
111  const ColorspaceType colorspace)
112 {
113  if ((colorspace == sRGBColorspace) || (colorspace == RGBColorspace) ||
114  (colorspace == scRGBColorspace) ||
115  (colorspace == TransparentColorspace) ||
116  (IsGrayColorspace(colorspace) != MagickFalse))
117  return(MagickTrue);
118  return(MagickFalse);
119 }
120 
121 #if defined(__cplusplus) || defined(c_plusplus)
122 }
123 #endif
124 
125 #endif
Definition: colorspace.h:44
ColorspaceType colorspace
Definition: pixel.h:110
Definition: colorspace.h:40
static MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:95
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:86
float MagickRealType
Definition: magick-type.h:79
#define MagickEpsilon
Definition: magick-type.h:142
MagickExport MagickRealType DecodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:187
static MagickBooleanType IsCMYKColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:78
MagickBooleanType
Definition: magick-type.h:214
static MagickBooleanType IssRGBCompatibleColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:110
Definition: pixel.h:104
Definition: colorspace.h:30
Definition: magick-type.h:217
static MagickBooleanType IssRGBColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:102
#define QuantumScale
Definition: magick-type.h:145
static void ConvertRGBToCMYK(MagickPixelPacket *pixel)
Definition: colorspace-private.h:31
Definition: colorspace.h:39
MagickRealType red
Definition: pixel.h:122
Definition: colorspace.h:46
Definition: magick-type.h:216
Definition: colorspace.h:28
MagickRealType green
Definition: pixel.h:122
Definition: colorspace.h:56
ColorspaceType
Definition: colorspace.h:25
Definition: colorspace.h:29
MagickRealType blue
Definition: pixel.h:122
static double PerceptibleReciprocal(const double x)
Definition: pixel-private.h:78
MagickRealType index
Definition: pixel.h:122
#define QuantumRange
Definition: magick-type.h:97