From: Cristy Date: Mon, 6 Mar 2017 00:13:42 +0000 (-0500) Subject: https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31460 X-Git-Tag: 7.0.5-2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbda8a245dcbd69d4e9a5f8306a7f70804e30d45;p=imagemagick https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31460 --- diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index 2264a3a83..44a9c479d 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -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); }