From: cristy Date: Fri, 16 Apr 2010 14:47:22 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~9640 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4846bb6a5f8535975997caa78c337500fa66dd57;p=imagemagick --- diff --git a/magick/colorspace.c b/magick/colorspace.c index 134c9516d..3039cc643 100644 --- a/magick/colorspace.c +++ b/magick/colorspace.c @@ -1253,19 +1253,22 @@ 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=((2.0*L-1.0)+0.160)/1.160; - x=(2.0*a-1.0)/5.000+y; - z=y-(2.0*b-1.0)/2.000; - if ((x*x*x) > (216.0/24389.0)) - x=x*x*x; - else - x=(x-16.0/116.0)/7.787; - if ((y*y*y) > (216.0/24389.0)) - y=y*y*y; + y=(100.0*L+16.0)/116.0; + x=255.0*(a > 0.5 ? a-1.0 : a)/500.0+y; + z=y-255.0*(b > 0.5 ? b-1.0 : b)/200.0; + cube=y*y*y; + if (cube > 0.008856) + y=cube; else y=(y-16.0/116.0)/7.787; - if ((z*z*z) > (216.0/24389.0)) - z=z*z*z; + cube=x*x*x; + if (cube > 0.008856) + x=cube; + else + x=(x-16.0/116.0)/7.787; + cube=z*z*z; + if (cube > 0.008856) + z=cube; else z=(z-16.0/116.0)/7.787; *X=0.9504559271*x; @@ -1299,6 +1302,18 @@ static inline void ConvertXYZToRGB(const double x,const double y,const double z, r=3.2407100*x-1.5372600*y-0.4985710*z; g=(-0.9692580*x+1.8759900*y+0.0415557*z); b=0.0556352*x-0.2039960*y+1.0570700*z; + if (r > 0.0031308) + r=1.055*pow(r,1.0/2.4)-0.055; + else + r*=12.92; + if (g > 0.0031308) + g=1.055*pow(g,1.0/2.4)-0.055; + else + g*=12.92; + if (b > 0.0031308) + b=1.055*pow(b,1.0/2.4)-0.055; + else + b*=12.92; *red=ClampToQuantum((MagickRealType) QuantumRange*r); *green=ClampToQuantum((MagickRealType) QuantumRange*g); *blue=ClampToQuantum((MagickRealType) QuantumRange*b);