]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/colorspace-private.h
(no commit message)
[imagemagick] / MagickCore / colorspace-private.h
index d5f598b59bd45d3bf73d7098ab4eaa0716e91c2f..7dfb8fda3389cc8f2bcf33e1a34ba1e6e98078a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
+  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
   dedicated to making software imaging solutions freely available.
   
   You may not use this file except in compliance with the License.
 #ifndef _MAGICKCORE_COLORSPACE_PRIVATE_H
 #define _MAGICKCORE_COLORSPACE_PRIVATE_H
 
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/pixel.h"
+#include "MagickCore/pixel-accessor.h"
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#include <MagickCore/image.h>
-#include <MagickCore/image-private.h>
-#include <MagickCore/pixel.h>
-#include <MagickCore/pixel-accessor.h>
-
 static inline void ConvertRGBToCMYK(PixelInfo *pixel)
 {
-  double
+  MagickRealType
     black,
     blue,
     cyan,
@@ -46,27 +46,27 @@ static inline void ConvertRGBToCMYK(PixelInfo *pixel)
     }
   else
     {
-      red=InversesRGBCompandor(pixel->red);
-      green=InversesRGBCompandor(pixel->green);
-      blue=InversesRGBCompandor(pixel->blue);
+      red=DecodePixelGamma(pixel->red);
+      green=DecodePixelGamma(pixel->green);
+      blue=DecodePixelGamma(pixel->blue);
     }
   if ((fabs(red) < MagickEpsilon) && (fabs(green) < MagickEpsilon) &&
       (fabs(blue) < MagickEpsilon))
     {
-      pixel->black=(double) QuantumRange;
+      pixel->black=(MagickRealType) QuantumRange;
       return;
     }
-  cyan=(double) (1.0-red);
-  magenta=(double) (1.0-green);
-  yellow=(double) (1.0-blue);
+  cyan=(MagickRealType) (1.0-red);
+  magenta=(MagickRealType) (1.0-green);
+  yellow=(MagickRealType) (1.0-blue);
   black=cyan;
   if (magenta < black)
     black=magenta;
   if (yellow < black)
     black=yellow;
-  cyan=(double) ((cyan-black)/(1.0-black));
-  magenta=(double) ((magenta-black)/(1.0-black));
-  yellow=(double) ((yellow-black)/(1.0-black));
+  cyan=(MagickRealType) ((cyan-black)/(1.0-black));
+  magenta=(MagickRealType) ((magenta-black)/(1.0-black));
+  yellow=(MagickRealType) ((yellow-black)/(1.0-black));
   pixel->colorspace=CMYKColorspace;
   pixel->red=QuantumRange*cyan;
   pixel->green=QuantumRange*magenta;
@@ -85,15 +85,14 @@ static inline MagickBooleanType IsCMYKColorspace(
 static inline MagickBooleanType IsGrayColorspace(
   const ColorspaceType colorspace)
 {
-  if ((colorspace == GRAYColorspace) || (colorspace == Rec601LumaColorspace) ||
-      (colorspace == Rec709LumaColorspace))
+  if (colorspace == GRAYColorspace)
     return(MagickTrue);
   return(MagickFalse);
 }
 
 static inline MagickBooleanType IsRGBColorspace(const ColorspaceType colorspace)
 {
-  if (colorspace == RGBColorspace)
+  if ((colorspace == RGBColorspace) || (colorspace == scRGBColorspace))
     return(MagickTrue);
   return(MagickFalse);
 }
@@ -109,8 +108,9 @@ static inline MagickBooleanType IssRGBColorspace(
 static inline MagickBooleanType IssRGBCompatibleColorspace(
   const ColorspaceType colorspace)
 {
-  if ((colorspace == sRGBColorspace) || (colorspace == TransparentColorspace) ||
-      (colorspace == RGBColorspace) || (colorspace == GRAYColorspace))
+  if ((colorspace == sRGBColorspace) || (colorspace == RGBColorspace) ||
+      (colorspace == scRGBColorspace) || 
+      (IsGrayColorspace(colorspace) != MagickFalse))
     return(MagickTrue);
   return(MagickFalse);
 }