From a4a3c5fdea89ee1dab2d4ef821f971106d157ee2 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 17 Jun 2012 02:18:22 +0000 Subject: [PATCH] --- MagickCore/colorspace-private.h | 6 +-- MagickCore/colorspace.c | 45 ++++++++++----------- MagickCore/gem.c | 72 ++++++++++++++++----------------- MagickCore/pixel-accessor.h | 28 ++++++------- MagickCore/xwindow-private.h | 6 +-- 5 files changed, 77 insertions(+), 80 deletions(-) diff --git a/MagickCore/colorspace-private.h b/MagickCore/colorspace-private.h index 0f9339c4c..053f3f9a4 100644 --- a/MagickCore/colorspace-private.h +++ b/MagickCore/colorspace-private.h @@ -42,9 +42,9 @@ static inline void ConvertsRGBToCMYK(PixelInfo *pixel) pixel->black=(MagickRealType) QuantumRange; return; } - cyan=(MagickRealType) (1.0-sRGBDecompanding(QuantumScale*pixel->red)); - magenta=(MagickRealType) (1.0-sRGBDecompanding(QuantumScale*pixel->green)); - yellow=(MagickRealType) (1.0-sRGBDecompanding(QuantumScale*pixel->blue)); + cyan=(MagickRealType) (1.0-DecompandsRGB(QuantumScale*pixel->red)); + magenta=(MagickRealType) (1.0-DecompandsRGB(QuantumScale*pixel->green)); + yellow=(MagickRealType) (1.0-DecompandsRGB(QuantumScale*pixel->blue)); black=cyan; if (magenta < black) black=magenta; diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index e9e513e53..6faad9e91 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -126,9 +126,9 @@ static inline void ConvertsRGBToXYZ(const Quantum red,const Quantum green, assert(X != (double *) NULL); assert(Y != (double *) NULL); assert(Z != (double *) NULL); - r=sRGBDecompanding(QuantumScale*red); - g=sRGBDecompanding(QuantumScale*green); - b=sRGBDecompanding(QuantumScale*blue); + r=DecompandsRGB(QuantumScale*red); + g=DecompandsRGB(QuantumScale*green); + b=DecompandsRGB(QuantumScale*blue); *X=0.4360747*r+0.3850649*g+0.1430804*b; *Y=0.2225045*r+0.7168786*g+0.0606169*b; *Z=0.0139322*r+0.0971045*g+0.7141733*b; @@ -260,12 +260,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, green, red; - red=QuantumRange*sRGBDecompanding(QuantumScale* - GetPixelRed(image,q)); - green=QuantumRange*sRGBDecompanding(QuantumScale* - GetPixelGreen(image,q)); - blue=QuantumRange*sRGBDecompanding(QuantumScale* - GetPixelBlue(image,q)); + red=QuantumRange*DecompandsRGB(QuantumScale*GetPixelRed(image,q)); + green=QuantumRange*DecompandsRGB(QuantumScale*GetPixelGreen(image,q)); + blue=QuantumRange*DecompandsRGB(QuantumScale*GetPixelBlue(image,q)); SetPixelCyan(image,ClampToQuantum((MagickRealType) (QuantumRange- red)),q); SetPixelMagenta(image,ClampToQuantum((MagickRealType) (QuantumRange- @@ -1177,11 +1174,11 @@ static MagickBooleanType sRGBTransformImage(Image *image, } for (x=0; x < (ssize_t) image->columns; x++) { - red=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + red=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*GetPixelRed(image,q)))); - green=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + green=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*GetPixelGreen(image,q)))); - blue=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + blue=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*GetPixelBlue(image,q)))); pixel.red=(x_map[red].x+y_map[green].x+z_map[blue].x)+ (MagickRealType) primary_info.x; @@ -1229,11 +1226,11 @@ static MagickBooleanType sRGBTransformImage(Image *image, PixelInfo pixel; - red=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + red=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*image->colormap[i].red))); - green=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + green=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*image->colormap[i].green))); - blue=ScaleQuantumToMap(ClampToQuantum(QuantumRange*sRGBDecompanding( + blue=ScaleQuantumToMap(ClampToQuantum(QuantumRange*DecompandsRGB( QuantumScale*image->colormap[i].blue))); pixel.red=x_map[red].x+y_map[green].x+z_map[blue].x+primary_info.x; pixel.green=x_map[red].y+y_map[green].y+z_map[blue].y+primary_info.y; @@ -1464,9 +1461,9 @@ static inline void ConvertXYZTosRGB(const double x,const double y,const double z r=3.1338561*x-1.6168667*y-0.4906146*z; g=(-0.9787684*x+1.9161415*y+0.0334540*z); b=0.0719453*x-0.2289914*y+1.4052427*z; - *red=RoundToQuantum((MagickRealType) QuantumRange*sRGBCompanding(r)); - *green=RoundToQuantum((MagickRealType) QuantumRange*sRGBCompanding(g)); - *blue=RoundToQuantum((MagickRealType) QuantumRange*sRGBCompanding(b)); + *red=RoundToQuantum((MagickRealType) QuantumRange*CompandsRGB(r)); + *green=RoundToQuantum((MagickRealType) QuantumRange*CompandsRGB(g)); + *blue=RoundToQuantum((MagickRealType) QuantumRange*CompandsRGB(b)); } static inline void ConvertCMYKTosRGB(PixelInfo *pixel) @@ -2698,11 +2695,11 @@ static MagickBooleanType TransformsRGBImage(Image *image, pixel.blue)]; #endif } - SetPixelRed(image,ClampToQuantum(QuantumRange*sRGBCompanding( + SetPixelRed(image,ClampToQuantum(QuantumRange*CompandsRGB( QuantumScale*ScaleMapToQuantum(pixel.red))),q); - SetPixelGreen(image,ClampToQuantum(QuantumRange*sRGBCompanding( + SetPixelGreen(image,ClampToQuantum(QuantumRange*CompandsRGB( QuantumScale*ScaleMapToQuantum(pixel.green))),q); - SetPixelBlue(image,ClampToQuantum(QuantumRange*sRGBCompanding( + SetPixelBlue(image,ClampToQuantum(QuantumRange*CompandsRGB( QuantumScale*ScaleMapToQuantum(pixel.blue))),q); q+=GetPixelChannels(image); } @@ -2763,11 +2760,11 @@ static MagickBooleanType TransformsRGBImage(Image *image, #endif } image->colormap[i].red=(double) ClampToQuantum(QuantumRange* - sRGBCompanding(QuantumScale*ScaleMapToQuantum(pixel.red))); + CompandsRGB(QuantumScale*ScaleMapToQuantum(pixel.red))); image->colormap[i].green=(double) ClampToQuantum(QuantumRange* - sRGBCompanding(QuantumScale*ScaleMapToQuantum(pixel.green))); + CompandsRGB(QuantumScale*ScaleMapToQuantum(pixel.green))); image->colormap[i].blue=(double) ClampToQuantum(QuantumRange* - sRGBCompanding(QuantumScale*ScaleMapToQuantum(pixel.blue))); + CompandsRGB(QuantumScale*ScaleMapToQuantum(pixel.blue))); } (void) SyncImage(image,exception); break; diff --git a/MagickCore/gem.c b/MagickCore/gem.c index 8f6a6ced0..6071ce20f 100644 --- a/MagickCore/gem.c +++ b/MagickCore/gem.c @@ -118,44 +118,44 @@ MagickPrivate void ConvertHSBTosRGB(const double hue,const double saturation, case 0: default: { - *red=QuantumRange*sRGBCompanding(brightness); - *green=QuantumRange*sRGBCompanding(t); - *blue=QuantumRange*sRGBCompanding(p); + *red=QuantumRange*CompandsRGB(brightness); + *green=QuantumRange*CompandsRGB(t); + *blue=QuantumRange*CompandsRGB(p); break; } case 1: { - *red=QuantumRange*sRGBCompanding(q); - *green=QuantumRange*sRGBCompanding(brightness); - *blue=QuantumRange*sRGBCompanding(p); + *red=QuantumRange*CompandsRGB(q); + *green=QuantumRange*CompandsRGB(brightness); + *blue=QuantumRange*CompandsRGB(p); break; } case 2: { - *red=QuantumRange*sRGBCompanding(p); - *green=QuantumRange*sRGBCompanding(brightness); - *blue=QuantumRange*sRGBCompanding(t); + *red=QuantumRange*CompandsRGB(p); + *green=QuantumRange*CompandsRGB(brightness); + *blue=QuantumRange*CompandsRGB(t); break; } case 3: { - *red=QuantumRange*sRGBCompanding(p); - *green=QuantumRange*sRGBCompanding(q); - *blue=QuantumRange*sRGBCompanding(brightness); + *red=QuantumRange*CompandsRGB(p); + *green=QuantumRange*CompandsRGB(q); + *blue=QuantumRange*CompandsRGB(brightness); break; } case 4: { - *red=QuantumRange*sRGBCompanding(t); - *green=QuantumRange*sRGBCompanding(p); - *blue=QuantumRange*sRGBCompanding(brightness); + *red=QuantumRange*CompandsRGB(t); + *green=QuantumRange*CompandsRGB(p); + *blue=QuantumRange*CompandsRGB(brightness); break; } case 5: { - *red=QuantumRange*sRGBCompanding(brightness); - *green=QuantumRange*sRGBCompanding(p); - *blue=QuantumRange*sRGBCompanding(q); + *red=QuantumRange*CompandsRGB(brightness); + *green=QuantumRange*CompandsRGB(p); + *blue=QuantumRange*CompandsRGB(q); break; } } @@ -235,9 +235,9 @@ MagickExport void ConvertHSLTosRGB(const double hue,const double saturation, r=ConvertHueTosRGB(m1,m2,hue+1.0/3.0); g=ConvertHueTosRGB(m1,m2,hue); b=ConvertHueTosRGB(m1,m2,hue-1.0/3.0); - *red=QuantumRange*sRGBCompanding(r); - *green=QuantumRange*sRGBCompanding(g); - *blue=QuantumRange*sRGBCompanding(b); + *red=QuantumRange*CompandsRGB(r); + *green=QuantumRange*CompandsRGB(g); + *blue=QuantumRange*CompandsRGB(b); } /* @@ -290,9 +290,9 @@ MagickPrivate void ConvertHWBTosRGB(const double hue,const double whiteness, v=1.0-blackness; if (hue == -1.0) { - *red=QuantumRange*sRGBCompanding(v); - *green=QuantumRange*sRGBCompanding(v); - *blue=QuantumRange*sRGBCompanding(v); + *red=QuantumRange*CompandsRGB(v); + *green=QuantumRange*CompandsRGB(v); + *blue=QuantumRange*CompandsRGB(v); return; } i=(ssize_t) floor(6.0*hue); @@ -311,9 +311,9 @@ MagickPrivate void ConvertHWBTosRGB(const double hue,const double whiteness, case 4: r=n; g=whiteness; b=v; break; case 5: r=v; g=whiteness; b=n; break; } - *red=QuantumRange*sRGBCompanding(r); - *green=QuantumRange*sRGBCompanding(g); - *blue=QuantumRange*sRGBCompanding(b); + *red=QuantumRange*CompandsRGB(r); + *green=QuantumRange*CompandsRGB(g); + *blue=QuantumRange*CompandsRGB(b); } /* @@ -364,9 +364,9 @@ MagickPrivate void ConvertsRGBToHSB(const double red,const double green, *hue=0.0; *saturation=0.0; *brightness=0.0; - r=QuantumRange*sRGBDecompanding(QuantumScale*red); - g=QuantumRange*sRGBDecompanding(QuantumScale*green); - b=QuantumRange*sRGBDecompanding(QuantumScale*blue); + r=QuantumRange*DecompandsRGB(QuantumScale*red); + g=QuantumRange*DecompandsRGB(QuantumScale*green); + b=QuantumRange*DecompandsRGB(QuantumScale*blue); min=r < g ? r : g; if (b < min) min=b; @@ -452,9 +452,9 @@ MagickExport void ConvertsRGBToHSL(const double red,const double green, assert(hue != (double *) NULL); assert(saturation != (double *) NULL); assert(lightness != (double *) NULL); - r=sRGBDecompanding(QuantumScale*red); - g=sRGBDecompanding(QuantumScale*green); - b=sRGBDecompanding(QuantumScale*blue); + r=DecompandsRGB(QuantumScale*red); + g=DecompandsRGB(QuantumScale*green); + b=DecompandsRGB(QuantumScale*blue); max=MagickMax(r,MagickMax(g,b)); min=MagickMin(r,MagickMin(g,b)); *lightness=(double) ((min+max)/2.0); @@ -531,9 +531,9 @@ MagickPrivate void ConvertsRGBToHWB(const double red,const double green, assert(hue != (double *) NULL); assert(whiteness != (double *) NULL); assert(blackness != (double *) NULL); - r=QuantumRange*sRGBDecompanding(QuantumScale*red); - g=QuantumRange*sRGBDecompanding(QuantumScale*green); - b=QuantumRange*sRGBDecompanding(QuantumScale*blue); + r=QuantumRange*DecompandsRGB(QuantumScale*red); + g=QuantumRange*DecompandsRGB(QuantumScale*green); + b=QuantumRange*DecompandsRGB(QuantumScale*blue); w=MagickMin(r,MagickMin(g,b)); v=MagickMax(r,MagickMax(g,b)); *blackness=1.0-QuantumScale*v; diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h index 26a3d15b3..491a70f16 100644 --- a/MagickCore/pixel-accessor.h +++ b/MagickCore/pixel-accessor.h @@ -31,14 +31,14 @@ extern "C" { #undef index -static inline double sRGBCompanding(const double intensity) +static inline double CompandsRGB(const double intensity) { if (intensity <= 0.0031308) return(intensity*12.92); return(1.055*pow(intensity,1.0/2.4)-0.055); } -static inline double sRGBDecompanding(const double intensity) +static inline double DecompandsRGB(const double intensity) { if (intensity <= 0.04045) return(intensity/12.92); @@ -197,9 +197,9 @@ static inline Quantum GetPixelInfoIntensity( } else { - red=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->red); - green=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->green); - blue=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->blue); + red=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->red); + green=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->green); + blue=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->blue); } #if !defined(MAGICKCORE_HDRI_SUPPORT) return((Quantum) (0.298839*red+0.586811*green+0.114350*blue+0.5)); @@ -227,9 +227,9 @@ static inline Quantum GetPixelInfoLuminance( } else { - red=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->red); - green=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->green); - blue=QuantumRange*sRGBDecompanding(QuantumScale*pixel_info->blue); + red=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->red); + green=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->green); + blue=QuantumRange*DecompandsRGB(QuantumScale*pixel_info->blue); } #if !defined(MAGICKCORE_HDRI_SUPPORT) luminance=(Quantum) (0.21267*red+0.71516*green+0.07217*blue+0.5); @@ -257,11 +257,11 @@ static inline Quantum GetPixelIntensity(const Image *restrict image, } else { - red=QuantumRange*sRGBDecompanding(QuantumScale* + red=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[RedPixelChannel].offset]); - green=QuantumRange*sRGBDecompanding(QuantumScale* + green=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[GreenPixelChannel].offset]); - blue=QuantumRange*sRGBDecompanding(QuantumScale* + blue=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[BluePixelChannel].offset]); } #if !defined(MAGICKCORE_HDRI_SUPPORT) @@ -298,11 +298,11 @@ static inline Quantum GetPixelLuminance(const Image *restrict image, } else { - red=QuantumRange*sRGBDecompanding(QuantumScale* + red=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[RedPixelChannel].offset]); - green=QuantumRange*sRGBDecompanding(QuantumScale* + green=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[GreenPixelChannel].offset]); - blue=QuantumRange*sRGBDecompanding(QuantumScale* + blue=QuantumRange*DecompandsRGB(QuantumScale* pixel[image->channel_map[BluePixelChannel].offset]); } #if !defined(MAGICKCORE_HDRI_SUPPORT) diff --git a/MagickCore/xwindow-private.h b/MagickCore/xwindow-private.h index c0710560a..62c887ce3 100644 --- a/MagickCore/xwindow-private.h +++ b/MagickCore/xwindow-private.h @@ -606,9 +606,9 @@ static inline MagickRealType XPixelIntensity(const XColor *pixel) MagickRealType intensity; - red=QuantumRange*sRGBDecompanding(QuantumScale*pixel->red); - green=QuantumRange*sRGBDecompanding(QuantumScale*pixel->green); - blue=QuantumRange*sRGBDecompanding(QuantumScale*pixel->blue); + red=QuantumRange*DecompandsRGB(QuantumScale*pixel->red); + green=QuantumRange*DecompandsRGB(QuantumScale*pixel->green); + blue=QuantumRange*DecompandsRGB(QuantumScale*pixel->blue); intensity=0.298839*red+0.586811*green+0.114350*blue; return(intensity); } -- 2.50.1