From bbda8a245dcbd69d4e9a5f8306a7f70804e30d45 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 5 Mar 2017 19:13:42 -0500 Subject: [PATCH] https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=31460 --- MagickCore/colorspace.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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); } -- 2.40.0