From: cristy Date: Mon, 6 May 2013 11:33:57 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~3730 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35605e9ee687899cf1c79cf27572fba678ce636e;p=imagemagick --- diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index 2ccd725f8..61cc59ece 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -1250,7 +1250,7 @@ static inline void ConvertLabToRGB(const double L,const double a, Y, Z; - ConvertLabToXYZ(L,a,b,&X,&Y,&Z); + ConvertLabToXYZ(100.0*L,255.0*(a-0.5),255.0*(b-0.5),&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,red,green,blue); } diff --git a/MagickCore/gem-private.h b/MagickCore/gem-private.h index 8f2fe592e..323f9ede5 100644 --- a/MagickCore/gem-private.h +++ b/MagickCore/gem-private.h @@ -84,9 +84,9 @@ static inline void ConvertLabToXYZ(const double L,const double a,const double b, assert(X != (double *) NULL); assert(Y != (double *) NULL); assert(Z != (double *) NULL); - y=(100.0*L+16.0)/116.0; - x=y+255.0*(a-0.5)/500.0; - z=y-255.0*(b-0.5)/200.0; + y=(L+16.0)/116.0; + x=y+a/500.0; + z=y-b/200.0; if ((x*x*x) > CIEEpsilon) x=(x*x*x); else @@ -94,7 +94,7 @@ static inline void ConvertLabToXYZ(const double L,const double a,const double b, if ((y*y*y) > CIEEpsilon) y=(y*y*y); else - y=(100.0*L)/CIEK; + y=L/CIEK; if ((z*z*z) > CIEEpsilon) z=(z*z*z); else diff --git a/MagickCore/gem.c b/MagickCore/gem.c index ee3375855..4b6b90518 100644 --- a/MagickCore/gem.c +++ b/MagickCore/gem.c @@ -737,15 +737,18 @@ MagickPrivate void ConvertHWBToRGB(const double hue,const double whiteness, % o red, green, blue: A pointer to a pixel component of type Quantum. % */ + +static inline void ConvertLCHabToXYZ(const double luma,const double chroma, + const double hue,double *X,double *Y,double *Z) +{ + ConvertLabToXYZ(luma,chroma*cos(hue*MagickPI/180.0),chroma* + sin(hue*MagickPI/180.0),X,Y,Z); +} + MagickPrivate void ConvertLCHabToRGB(const double luma,const double chroma, const double hue,double *red,double *green,double *blue) { double - a, - b, - C, - H, - L, X, Y, Z; @@ -756,13 +759,7 @@ MagickPrivate void ConvertLCHabToRGB(const double luma,const double chroma, assert(red != (double *) NULL); assert(green != (double *) NULL); assert(blue != (double *) NULL); - L=luma; - C=chroma; - H=hue; - a=C*cos(360.0*H*MagickPI/180.0); - b=C*sin(360.0*H*MagickPI/180.0); - ConvertLabToXYZ(((116.0*L)-16.0)/100.0,(500.0*a)/255.0+0.5,(200.0*b)/255.0+ - 0.5,&X,&Y,&Z); + ConvertLCHabToXYZ(luma*100.0,255.0*(chroma-0.5),255.0*(hue-0.5),&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,red,green,blue); }