]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/gem.c
(no commit message)
[imagemagick] / MagickCore / gem.c
index c28f01ee71b4fc9c4171c362b251935a3acf89b7..7085742e1137a56033a9274e6f1aeaa7c01935e0 100644 (file)
 %                    Graphic Gems - Graphic Support Methods                   %
 %                                                                             %
 %                               Software Design                               %
-%                                 John Cristy                                 %
+%                                    Cristy                                   %
 %                                 August 1996                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2013 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.  You may  %
@@ -391,7 +391,7 @@ MagickPrivate void ConvertHSIToRGB(const double hue,const double saturation,
 {
   double
     b,
-    g
+    g,
     h,
     r;
 
@@ -762,7 +762,7 @@ MagickPrivate void ConvertLCHabToRGB(const double luma,const double chroma,
   assert(red != (double *) NULL);
   assert(green != (double *) NULL);
   assert(blue != (double *) NULL);
-  ConvertLCHabToXYZ(100.0*luma,255.0*(chroma-0.5),255.0*(hue-0.5),&X,&Y,&Z);
+  ConvertLCHabToXYZ(100.0*luma,255.0*(chroma-0.5),360.0*hue,&X,&Y,&Z);
   ConvertXYZToRGB(X,Y,Z,red,green,blue);
 }
 \f
@@ -815,7 +815,7 @@ MagickPrivate void ConvertLCHuvToRGB(const double luma,const double chroma,
   assert(red != (double *) NULL);
   assert(green != (double *) NULL);
   assert(blue != (double *) NULL);
-  ConvertLCHuvToXYZ(100.0*luma,354.0*chroma-134.0,262.0*hue-140.0,&X,&Y,&Z);
+  ConvertLCHuvToXYZ(100.0*luma,255.0*(chroma-0.5),360.0*hue,&X,&Y,&Z);
   ConvertXYZToRGB(X,Y,Z,red,green,blue);
 }
 \f
@@ -1342,10 +1342,8 @@ static inline void ConvertXYZToLCHab(const double X,const double Y,
     b;
 
   ConvertXYZToLab(X,Y,Z,luma,&a,&b);
-  *chroma=hypot(255.0*(a-0.5),255.0*(b-0.5));
-  *hue=180.0*atan2(255.0*(b-0.5),255.0*(a-0.5))/MagickPI;
-  *chroma=(*chroma)/255.0+0.5;
-  *hue=(*hue)/255.0+0.5;
+  *chroma=hypot(255.0*(a-0.5),255.0*(b-0.5))/255.0+0.5;
+  *hue=180.0*atan2(255.0*(b-0.5),255.0*(a-0.5))/MagickPI/360.0;
   if (*hue < 0.0)
     *hue+=1.0;
 }
@@ -1405,10 +1403,8 @@ static inline void ConvertXYZToLCHuv(const double X,const double Y,
     v;
 
   ConvertXYZToLuv(X,Y,Z,luma,&u,&v);
-  *chroma=hypot(354.0*u-134.0,262.0*v-140.0);
-  *hue=180.0*atan2(262.0*v-140.0,354.0*u-134.0)/MagickPI;
-  *chroma=(*chroma+134.0)/354.0;
-  *hue=(*hue+140.0)/262.0;
+  *chroma=hypot(354.0*u-134.0,262.0*v-140.0)/255.0+0.5;
+  *hue=180.0*atan2(262.0*v-140.0,354.0*u-134.0)/MagickPI/360.0;
   if (*hue < 0.0)
     *hue+=1.0;
 }