MagickCore
6.8.5
colorspace-private.h
Go to the documentation of this file.
1
/*
2
Copyright 1999-2013 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
#if defined(__cplusplus) || defined(c_plusplus)
22
extern
"C"
{
23
#endif
24
25
#include "
magick/image.h
"
26
#include "
magick/image-private.h
"
27
#include "
magick/pixel.h
"
28
#include "
magick/pixel-accessor.h
"
29
30
static
inline
void
ConvertRGBToCMYK
(
MagickPixelPacket
*pixel)
31
{
32
MagickRealType
33
black,
34
blue,
35
cyan,
36
green,
37
magenta,
38
red,
39
yellow;
40
41
if
(pixel->
colorspace
!=
sRGBColorspace
)
42
{
43
red=
QuantumScale
*pixel->
red
;
44
green=
QuantumScale
*pixel->
green
;
45
blue=
QuantumScale
*pixel->
blue
;
46
}
47
else
48
{
49
red=
DecodePixelGamma
(pixel->
red
);
50
green=
DecodePixelGamma
(pixel->
green
);
51
blue=
DecodePixelGamma
(pixel->
blue
);
52
}
53
if
((fabs(red) <
MagickEpsilon
) && (fabs(green) <
MagickEpsilon
) &&
54
(fabs(blue) <
MagickEpsilon
))
55
{
56
pixel->
index
=(
MagickRealType
)
QuantumRange
;
57
return
;
58
}
59
cyan=(
MagickRealType
) (1.0-red);
60
magenta=(
MagickRealType
) (1.0-green);
61
yellow=(
MagickRealType
) (1.0-blue);
62
black=cyan;
63
if
(magenta < black)
64
black=magenta;
65
if
(yellow < black)
66
black=yellow;
67
cyan=(
MagickRealType
) ((cyan-black)/(1.0-black));
68
magenta=(
MagickRealType
) ((magenta-black)/(1.0-black));
69
yellow=(
MagickRealType
) ((yellow-black)/(1.0-black));
70
pixel->
colorspace
=
CMYKColorspace
;
71
pixel->
red
=
QuantumRange
*cyan;
72
pixel->
green
=
QuantumRange
*magenta;
73
pixel->
blue
=
QuantumRange
*yellow;
74
pixel->
index
=
QuantumRange
*black;
75
}
76
77
static
inline
MagickBooleanType
IsCMYKColorspace
(
78
const
ColorspaceType
colorspace)
79
{
80
if
(colorspace ==
CMYKColorspace
)
81
return
(
MagickTrue
);
82
return
(
MagickFalse
);
83
}
84
85
static
inline
MagickBooleanType
IsGrayColorspace
(
86
const
ColorspaceType
colorspace)
87
{
88
if
((colorspace ==
GRAYColorspace
) || (colorspace ==
Rec601LumaColorspace
) ||
89
(colorspace ==
Rec709LumaColorspace
))
90
return
(
MagickTrue
);
91
return
(
MagickFalse
);
92
}
93
94
static
inline
MagickBooleanType
IsRGBColorspace
(
const
ColorspaceType
colorspace)
95
{
96
if
((colorspace ==
RGBColorspace
) || (colorspace ==
scRGBColorspace
))
97
return
(
MagickTrue
);
98
return
(
MagickFalse
);
99
}
100
101
static
inline
MagickBooleanType
IssRGBColorspace
(
102
const
ColorspaceType
colorspace)
103
{
104
if
((colorspace ==
sRGBColorspace
) || (colorspace ==
TransparentColorspace
))
105
return
(
MagickTrue
);
106
return
(
MagickFalse
);
107
}
108
109
static
inline
MagickBooleanType
IssRGBCompatibleColorspace
(
110
const
ColorspaceType
colorspace)
111
{
112
if
((colorspace ==
sRGBColorspace
) || (colorspace ==
RGBColorspace
) ||
113
(colorspace ==
scRGBColorspace
) || (colorspace ==
GRAYColorspace
) ||
114
(colorspace ==
TransparentColorspace
))
115
return
(
MagickTrue
);
116
return
(
MagickFalse
);
117
}
118
119
#if defined(__cplusplus) || defined(c_plusplus)
120
}
121
#endif
122
123
#endif
magick
colorspace-private.h
Generated by
1.8.1.2