MagickCore: colorspace-private.h Source File

# colorspace-private.h

Go to the documentation of this file.

    00001 /*
    00002   Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization
    00003   dedicated to making software imaging solutions freely available.
    00004
    00005   You may not use this file except in compliance with the License.
    00006   obtain a copy of the License at
    00007
    00008     http://www.imagemagick.org/script/license.php
    00009
    00010   Unless required by applicable law or agreed to in writing, software
    00011   distributed under the License is distributed on an "AS IS" BASIS,
    00012   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013   See the License for the specific language governing permissions and
    00014   limitations under the License.
    00015
    00016   MagickCore image colorspace private methods.
    00017 */
    00018 #ifndef _MAGICKCORE_COLORSPACE_PRIVATE_H
    00019 #define _MAGICKCORE_COLORSPACE_PRIVATE_H
    00020
    00021 #if defined(__cplusplus) || defined(c_plusplus)
    00022 extern "C" {
    00023 #endif
    00024
    00025 #include <magick/pixel.h>
    00026
    00027 static inline void ConvertRGBToCMYK(MagickPixelPacket *pixel)
    00028 {
    00029   MagickRealType
    00030     black,
    00031     cyan,
    00032     magenta,
    00033     yellow;
    00034
    00035   cyan=(MagickRealType) (QuantumRange-pixel->red);
    00036   magenta=(MagickRealType) (QuantumRange-pixel->green);
    00037   yellow=(MagickRealType) (QuantumRange-pixel->blue);
    00038   black=(MagickRealType) QuantumRange;
    00039   if (cyan < black)
    00040     black=cyan;
    00041   if (magenta < black)
    00042     black=magenta;
    00043   if (yellow < black)
    00044     black=yellow;
    00045   if (black == QuantumRange)
    00046     {
    00047       cyan=0.0;
    00048       magenta=0.0;
    00049       yellow=0.0;
    00050     }
    00051   else
    00052     {
    00053       cyan=(MagickRealType) (QuantumRange*(cyan-black)/
    00054         (QuantumRange-black));
    00055       magenta=(MagickRealType) (QuantumRange*(magenta-black)/
    00056         (QuantumRange-black));
    00057       yellow=(MagickRealType) (QuantumRange*(yellow-black)/
    00058         (QuantumRange-black));
    00059     }
    00060   pixel->colorspace=CMYKColorspace;
    00061   pixel->red=cyan;
    00062   pixel->green=magenta;
    00063   pixel->blue=yellow;
    00064   pixel->index=black;
    00065 }
    00066
    00067 #if defined(__cplusplus) || defined(c_plusplus)
    00068 }
    00069 #endif
    00070
    00071 #endif