root / ImageMagick / branches / ImageMagick-6.3.5 / magick / colorspace-private.h

Revision 8037, 1.9 kB (checked in by cristy, 14 months ago)
Line 
1/*
2  Copyright 1999-2007 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)
22extern "C" {
23#endif
24
25#include <magick/pixel.h>
26
27static inline void ConvertRGBToCMYK(MagickPixelPacket *pixel)
28{
29  MagickRealType
30    black,
31    cyan,
32    magenta,
33    yellow;
34                                                                               
35  cyan=(MagickRealType) (QuantumRange-pixel->red);
36  magenta=(MagickRealType) (QuantumRange-pixel->green);
37  yellow=(MagickRealType) (QuantumRange-pixel->blue);
38  black=(MagickRealType) QuantumRange;
39  if (cyan < black)
40    black=cyan;
41  if (magenta < black)
42    black=magenta;
43  if (yellow < black)
44    black=yellow;
45  if (black == QuantumRange)
46    {
47      cyan=0.0;
48      magenta=0.0;
49      yellow=0.0;
50    }
51  else
52    {
53      cyan=(MagickRealType) (QuantumRange*(cyan-black)/
54        (QuantumRange-black));
55      magenta=(MagickRealType) (QuantumRange*(magenta-black)/
56        (QuantumRange-black));
57      yellow=(MagickRealType) (QuantumRange*(yellow-black)/
58        (QuantumRange-black));
59    }
60  pixel->colorspace=CMYKColorspace;
61  pixel->red=cyan;
62  pixel->green=magenta;
63  pixel->blue=yellow;
64  pixel->index=black;
65}
66
67#if defined(__cplusplus) || defined(c_plusplus)
68}
69#endif
70
71#endif
Note: See TracBrowser for help on using the browser.