]> granicus.if.org Git - imagemagick/commitdiff
https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31460
authorCristy <urban-warrior@imagemagick.org>
Mon, 6 Mar 2017 00:13:42 +0000 (19:13 -0500)
committerCristy <urban-warrior@imagemagick.org>
Mon, 6 Mar 2017 00:13:42 +0000 (19:13 -0500)
MagickCore/colorspace.c

index 2264a3a8312de170940460414b8b5381f961a94c..44a9c479d63134566e56c4004a5a1a3d5e5c8306 100644 (file)
@@ -172,13 +172,15 @@ static void ConvertRGBToxyY(const double red,const double green,
   const double blue,double *low_x,double *low_y,double *cap_Y)
 {
   double
+    gamma,
     X,
     Y,
     Z;
 
   ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
-  *low_x=X/(X+Y+Z);
-  *low_y=Y/(X+Y+Z);
+  gamma=PerceptibleReciprocal(X+Y+Z);
+  *low_x=gamma*X;
+  *low_y=gamma*Y;
   *cap_Y=Y;
 }
 
@@ -1395,13 +1397,16 @@ static inline void ConvertxyYToRGB(const double low_x,const double low_y,
   const double cap_Y,double *red,double *green,double *blue)
 {
   double
+    gamma,
     X,
     Y,
     Z;
 
-  X=cap_Y/low_y*low_x;
+  gamma=PerceptibleReciprocal(low_y*low_x);
+  X=gamma*cap_Y;
   Y=cap_Y;
-  Z=cap_Y/low_y*(1.0-low_x-low_y);
+  gamma=PerceptibleReciprocal(low_y);
+  Z=gamma*cap_Y*(1.0-low_x-low_y);
   ConvertXYZToRGB(X,Y,Z,red,green,blue);
 }