MagickCore  6.9.10
Convert, Edit, Or Compose Bitmap Images
colorspace-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2019 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  https://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 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
30 static inline void ConvertCMYKToRGB(MagickPixelPacket *pixel)
31 {
32  pixel->red=((QuantumRange-(QuantumScale*pixel->red*(QuantumRange-
33  pixel->index)+pixel->index)));
35  pixel->index)+pixel->index)));
37  pixel->index)+pixel->index)));
38 }
39 
40 static inline void ConvertRGBToCMYK(MagickPixelPacket *pixel)
41 {
43  black,
44  blue,
45  cyan,
46  green,
47  magenta,
48  red,
49  yellow;
50 
51  if (pixel->colorspace != sRGBColorspace)
52  {
53  red=QuantumScale*pixel->red;
54  green=QuantumScale*pixel->green;
55  blue=QuantumScale*pixel->blue;
56  }
57  else
58  {
59  red=QuantumScale*DecodePixelGamma(pixel->red);
60  green=QuantumScale*DecodePixelGamma(pixel->green);
61  blue=QuantumScale*DecodePixelGamma(pixel->blue);
62  }
63  if ((fabs((double) red) < MagickEpsilon) &&
64  (fabs((double) green) < MagickEpsilon) &&
65  (fabs((double) blue) < MagickEpsilon))
66  {
68  return;
69  }
70  cyan=(MagickRealType) (1.0-red);
71  magenta=(MagickRealType) (1.0-green);
72  yellow=(MagickRealType) (1.0-blue);
73  black=cyan;
74  if (magenta < black)
75  black=magenta;
76  if (yellow < black)
77  black=yellow;
78  cyan=(MagickRealType) ((cyan-black)/(1.0-black));
79  magenta=(MagickRealType) ((magenta-black)/(1.0-black));
80  yellow=(MagickRealType) ((yellow-black)/(1.0-black));
82  pixel->red=QuantumRange*cyan;
83  pixel->green=QuantumRange*magenta;
84  pixel->blue=QuantumRange*yellow;
85  pixel->index=QuantumRange*black;
86 }
87 
89  const ColorspaceType colorspace)
90 {
91  if (colorspace == CMYKColorspace)
92  return(MagickTrue);
93  return(MagickFalse);
94 }
95 
97  const ColorspaceType colorspace)
98 {
99  if ((colorspace == LinearGRAYColorspace) || (colorspace == GRAYColorspace) ||
100  (colorspace == Rec601LumaColorspace) ||
101  (colorspace == Rec709LumaColorspace))
102  return(MagickTrue);
103  return(MagickFalse);
104 }
105 
106 static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
107 {
108  if ((colorspace == RGBColorspace) || (colorspace == scRGBColorspace))
109  return(MagickTrue);
110  return(MagickFalse);
111 }
112 
114  const ColorspaceType colorspace)
115 {
116  if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace))
117  return(MagickTrue);
118  return(MagickFalse);
119 }
120 
122  const ColorspaceType colorspace)
123 {
124  if ((colorspace == sRGBColorspace) || (colorspace == RGBColorspace) ||
125  (colorspace == scRGBColorspace) || (colorspace == TransparentColorspace) ||
126  (colorspace == GRAYColorspace) || (colorspace == LinearGRAYColorspace))
127  return(MagickTrue);
128  return(MagickFalse);
129 }
130 
131 #if defined(__cplusplus) || defined(c_plusplus)
132 }
133 #endif
134 
135 #endif
static MagickBooleanType IssRGBColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:113
static MagickBooleanType IsGrayColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:96
static MagickBooleanType IsCMYKColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:88
static void ConvertRGBToCMYK(MagickPixelPacket *pixel)
Definition: colorspace-private.h:40
static void ConvertCMYKToRGB(MagickPixelPacket *pixel)
Definition: colorspace-private.h:30
static MagickBooleanType IssRGBCompatibleColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:121
static MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
Definition: colorspace-private.h:106
ColorspaceType
Definition: colorspace.h:26
@ Rec601LumaColorspace
Definition: colorspace.h:44
@ scRGBColorspace
Definition: colorspace.h:56
@ RGBColorspace
Definition: colorspace.h:28
@ CMYKColorspace
Definition: colorspace.h:39
@ Rec709LumaColorspace
Definition: colorspace.h:46
@ GRAYColorspace
Definition: colorspace.h:29
@ TransparentColorspace
Definition: colorspace.h:30
@ sRGBColorspace
Definition: colorspace.h:40
@ LinearGRAYColorspace
Definition: colorspace.h:62
MagickDoubleType MagickRealType
Definition: magick-type.h:129
#define QuantumRange
Definition: magick-type.h:90
#define MagickEpsilon
Definition: magick-type.h:119
MagickBooleanType
Definition: magick-type.h:196
@ MagickFalse
Definition: magick-type.h:197
@ MagickTrue
Definition: magick-type.h:198
#define QuantumScale
Definition: magick-type.h:124
MagickExport MagickRealType DecodePixelGamma(const MagickRealType pixel)
Definition: pixel.c:255
Definition: pixel.h:105
ColorspaceType colorspace
Definition: pixel.h:110
MagickRealType blue
Definition: pixel.h:124
MagickRealType index
Definition: pixel.h:126
MagickRealType green
Definition: pixel.h:123
MagickRealType red
Definition: pixel.h:122