From: cristy Date: Wed, 10 Oct 2012 22:44:05 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4862 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36abbdf33560fabb60c95ac29b209d2604579b65;p=imagemagick --- diff --git a/Magick++/lib/Magick++/Include.h b/Magick++/lib/Magick++/Include.h index f5dde9b3f..3be5c96bc 100644 --- a/Magick++/lib/Magick++/Include.h +++ b/Magick++/lib/Magick++/Include.h @@ -23,6 +23,7 @@ #include #include #include +#include #if defined(MAGICKCORE_HAVE_SYS_TYPES_H) # include diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 9ac7fefd2..8a655bda6 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -714,7 +714,7 @@ MagickExport Image *SeparateImage(const Image *image, continue; pixel=p[i]; if (IssRGBColorspace(image->colorspace) != MagickFalse) - pixel=InversesRGBCompandor(pixel); + pixel=DecodesRGBGamma(pixel); SetPixelChannel(separate_image,GrayPixelChannel,ClampToQuantum(pixel), q); } diff --git a/MagickCore/colorspace-private.h b/MagickCore/colorspace-private.h index d5f598b59..1b697f02d 100644 --- a/MagickCore/colorspace-private.h +++ b/MagickCore/colorspace-private.h @@ -46,9 +46,9 @@ static inline void ConvertRGBToCMYK(PixelInfo *pixel) } else { - red=InversesRGBCompandor(pixel->red); - green=InversesRGBCompandor(pixel->green); - blue=InversesRGBCompandor(pixel->blue); + red=DecodesRGBGamma(pixel->red); + green=DecodesRGBGamma(pixel->green); + blue=DecodesRGBGamma(pixel->blue); } if ((fabs(red) < MagickEpsilon) && (fabs(green) < MagickEpsilon) && (fabs(blue) < MagickEpsilon)) diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index 60eaace67..f45730030 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -294,9 +294,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, magenta, yellow; - cyan=InversesRGBCompandor((double) GetPixelCyan(image,q)); - magenta=InversesRGBCompandor((double) GetPixelMagenta(image,q)); - yellow=InversesRGBCompandor((double) GetPixelYellow(image,q)); + cyan=DecodesRGBGamma((double) GetPixelCyan(image,q)); + magenta=DecodesRGBGamma((double) GetPixelMagenta(image,q)); + yellow=DecodesRGBGamma((double) GetPixelYellow(image,q)); SetPixelCyan(image,ClampToQuantum(QuantumRange-cyan),q); SetPixelMagenta(image,ClampToQuantum(QuantumRange-magenta),q); SetPixelYellow(image,ClampToQuantum(QuantumRange-yellow),q); @@ -363,9 +363,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, for (x=0; x < (ssize_t) image->columns; x++) { GetPixelInfoPixel(image,q,&pixel); - pixel.red=InversesRGBCompandor(pixel.red); - pixel.green=InversesRGBCompandor(pixel.green); - pixel.blue=InversesRGBCompandor(pixel.blue); + pixel.red=DecodesRGBGamma(pixel.red); + pixel.green=DecodesRGBGamma(pixel.green); + pixel.blue=DecodesRGBGamma(pixel.blue); ConvertRGBToCMYK(&pixel); SetPixelInfoPixel(image,&pixel,q); q+=GetPixelChannels(image); @@ -427,9 +427,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, green, red; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); gray=0.298839*red+0.586811*green+0.114350*blue; SetPixelGray(image,ClampToQuantum(gray),q); q+=GetPixelChannels(image); @@ -491,9 +491,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, luma, red; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToHCL(red,green,blue,&hue,&chroma,&luma); SetPixelRed(image,ClampToQuantum(QuantumRange*hue),q); SetPixelGreen(image,ClampToQuantum(QuantumRange*chroma),q); @@ -556,9 +556,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, red, saturation; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToHSB(red,green,blue,&hue,&saturation,&brightness); SetPixelRed(image,ClampToQuantum(QuantumRange*hue),q); SetPixelGreen(image,ClampToQuantum(QuantumRange*saturation),q); @@ -621,9 +621,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, red, saturation; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToHSL(red,green,blue,&hue,&saturation,&lightness); SetPixelRed(image,ClampToQuantum(QuantumRange*hue),q); SetPixelGreen(image,ClampToQuantum(QuantumRange*saturation),q); @@ -686,9 +686,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, red, whiteness; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToHWB(red,green,blue,&hue,&whiteness,&blackness); SetPixelRed(image,ClampToQuantum(QuantumRange*hue),q); SetPixelGreen(image,ClampToQuantum(QuantumRange*whiteness),q); @@ -754,9 +754,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, Y, Z; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); ConvertXYZToLab(X,Y,Z,&L,&a,&b); SetPixelRed(image,ClampToQuantum(QuantumRange*L),q); @@ -825,9 +825,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, Y, Z; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); ConvertXYZToLab(X,Y,Z,&L,&a,&b); C=sqrt(a*a+b*b); @@ -898,9 +898,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, Y, Z; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); ConvertXYZToLMS(X,Y,Z,&L,&M,&S); SetPixelRed(image,ClampToQuantum(QuantumRange*L),q); @@ -1005,9 +1005,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, green, red; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); SetPixelRed(image,logmap[ScaleQuantumToMap( ClampToQuantum(red))],q); SetPixelGreen(image,logmap[ScaleQuantumToMap( @@ -1076,9 +1076,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, Y, Z; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); ConvertXYZToLuv(X,Y,Z,&L,&u,&v); SetPixelRed(image,ClampToQuantum(QuantumRange*L),q); @@ -1140,9 +1140,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, green, red; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); gray=0.212600*red+0.715200*green+0.072200*blue; SetPixelGray(image,ClampToQuantum(gray),q); q+=GetPixelChannels(image); @@ -1201,9 +1201,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, green, red; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); SetPixelRed(image,ClampToQuantum(red),q); SetPixelGreen(image,ClampToQuantum(green),q); SetPixelBlue(image,ClampToQuantum(blue),q); @@ -1265,9 +1265,9 @@ static MagickBooleanType sRGBTransformImage(Image *image, Y, Z; - red=InversesRGBCompandor((double) GetPixelRed(image,q)); - green=InversesRGBCompandor((double) GetPixelGreen(image,q)); - blue=InversesRGBCompandor((double) GetPixelBlue(image,q)); + red=DecodesRGBGamma((double) GetPixelRed(image,q)); + green=DecodesRGBGamma((double) GetPixelGreen(image,q)); + blue=DecodesRGBGamma((double) GetPixelBlue(image,q)); ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); SetPixelRed(image,ClampToQuantum(QuantumRange*X),q); SetPixelGreen(image,ClampToQuantum(QuantumRange*Y),q); @@ -1605,11 +1605,11 @@ static MagickBooleanType sRGBTransformImage(Image *image, } for (x=0; x < (ssize_t) image->columns; x++) { - red=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor((double) + red=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma((double) GetPixelRed(image,q)))); - green=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor((double) + green=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma((double) GetPixelGreen(image,q)))); - blue=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor((double) + blue=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma((double) GetPixelBlue(image,q)))); pixel.red=(x_map[red].x+y_map[green].x+z_map[blue].x)+ primary_info.x; @@ -1657,11 +1657,11 @@ static MagickBooleanType sRGBTransformImage(Image *image, PixelInfo pixel; - red=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor( + red=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma( image->colormap[i].red))); - green=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor( + green=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma( image->colormap[i].green))); - blue=ScaleQuantumToMap(ClampToQuantum(InversesRGBCompandor( + blue=ScaleQuantumToMap(ClampToQuantum(DecodesRGBGamma( 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; @@ -2258,11 +2258,11 @@ static MagickBooleanType TransformsRGBImage(Image *image, magenta, yellow; - cyan=sRGBCompandor((double) (QuantumRange- + cyan=EncodesRGBGamma((double) (QuantumRange- GetPixelCyan(image,q))); - magenta=sRGBCompandor((double) (QuantumRange- + magenta=EncodesRGBGamma((double) (QuantumRange- GetPixelMagenta(image,q))); - yellow=sRGBCompandor((double) (QuantumRange- + yellow=EncodesRGBGamma((double) (QuantumRange- GetPixelYellow(image,q))); SetPixelCyan(image,ClampToQuantum(cyan),q); SetPixelMagenta(image,ClampToQuantum(magenta),q); @@ -2327,9 +2327,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, { GetPixelInfoPixel(image,q,&pixel); ConvertCMYKToRGB(&pixel); - pixel.red=sRGBCompandor(pixel.red); - pixel.green=sRGBCompandor(pixel.green); - pixel.blue=sRGBCompandor(pixel.blue); + pixel.red=EncodesRGBGamma(pixel.red); + pixel.green=EncodesRGBGamma(pixel.green); + pixel.blue=EncodesRGBGamma(pixel.blue); SetPixelInfoPixel(image,&pixel,q); q+=GetPixelChannels(image); } @@ -2388,7 +2388,7 @@ static MagickBooleanType TransformsRGBImage(Image *image, double gray; - gray=sRGBCompandor((double) GetPixelGray(image,q)); + gray=EncodesRGBGamma((double) GetPixelGray(image,q)); SetPixelRed(image,ClampToQuantum(gray),q); SetPixelGreen(image,ClampToQuantum(gray),q); SetPixelBlue(image,ClampToQuantum(gray),q); @@ -2454,9 +2454,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, chroma=(double) (QuantumScale*GetPixelGreen(image,q)); luma=(double) (QuantumScale*GetPixelBlue(image,q)); ConvertHCLToRGB(hue,chroma,luma,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2519,9 +2519,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, saturation=(double) (QuantumScale*GetPixelGreen(image,q)); brightness=(double) (QuantumScale*GetPixelBlue(image,q)); ConvertHSBToRGB(hue,saturation,brightness,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2584,9 +2584,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, saturation=(double) (QuantumScale*GetPixelGreen(image,q)); lightness=(double) (QuantumScale*GetPixelBlue(image,q)); ConvertHSLToRGB(hue,saturation,lightness,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2649,9 +2649,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, whiteness=(double) (QuantumScale*GetPixelGreen(image,q)); blackness=(double) (QuantumScale*GetPixelBlue(image,q)); ConvertHWBToRGB(hue,whiteness,blackness,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2718,9 +2718,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, b=QuantumScale*GetPixelBlue(image,q); ConvertLabToXYZ(L,a,b,&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2791,9 +2791,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, b=C*sin(H*(MagickPI/180.0)); ConvertLabToXYZ(L,a,b,&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2860,9 +2860,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, S=QuantumScale*GetPixelBlue(image,q); ConvertLMSToXYZ(L,M,S,&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -2964,11 +2964,11 @@ static MagickBooleanType TransformsRGBImage(Image *image, green, red; - red=sRGBCompandor((double) logmap[ScaleQuantumToMap( + red=EncodesRGBGamma((double) logmap[ScaleQuantumToMap( GetPixelRed(image,q))]); - green=sRGBCompandor((double) logmap[ScaleQuantumToMap( + green=EncodesRGBGamma((double) logmap[ScaleQuantumToMap( GetPixelGreen(image,q))]); - blue=sRGBCompandor((double) logmap[ScaleQuantumToMap( + blue=EncodesRGBGamma((double) logmap[ScaleQuantumToMap( GetPixelBlue(image,q))]); SetPixelRed(image,ClampToQuantum(red),q); SetPixelGreen(image,ClampToQuantum(green),q); @@ -3040,9 +3040,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, v=QuantumScale*GetPixelBlue(image,q); ConvertLuvToXYZ(L,u,v,&X,&Y,&Z); ConvertXYZToRGB(X,Y,Z,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -3098,9 +3098,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, green, red; - red=sRGBCompandor((double) GetPixelRed(image,q)); - green=sRGBCompandor((double) GetPixelGreen(image,q)); - blue=sRGBCompandor((double) GetPixelBlue(image,q)); + red=EncodesRGBGamma((double) GetPixelRed(image,q)); + green=EncodesRGBGamma((double) GetPixelGreen(image,q)); + blue=EncodesRGBGamma((double) GetPixelBlue(image,q)); SetPixelRed(image,ClampToQuantum(red),q); SetPixelGreen(image,ClampToQuantum(green),q); SetPixelBlue(image,ClampToQuantum(blue),q); @@ -3166,9 +3166,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, Y=QuantumScale*GetPixelGreen(image,q); Z=QuantumScale*GetPixelBlue(image,q); ConvertXYZToRGB(X,Y,Z,&red,&green,&blue); - SetPixelRed(image,ClampToQuantum(sRGBCompandor(red)),q); - SetPixelGreen(image,ClampToQuantum(sRGBCompandor(green)),q); - SetPixelBlue(image,ClampToQuantum(sRGBCompandor(blue)),q); + SetPixelRed(image,ClampToQuantum(EncodesRGBGamma(red)),q); + SetPixelGreen(image,ClampToQuantum(EncodesRGBGamma(green)),q); + SetPixelBlue(image,ClampToQuantum(EncodesRGBGamma(blue)),q); q+=GetPixelChannels(image); } sync=SyncCacheViewAuthenticPixels(image_view,exception); @@ -3508,9 +3508,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, } else { - pixel.red=sRGBCompandor(pixel.red); - pixel.green=sRGBCompandor(pixel.green); - pixel.blue=sRGBCompandor(pixel.blue); + pixel.red=EncodesRGBGamma(pixel.red); + pixel.green=EncodesRGBGamma(pixel.green); + pixel.blue=EncodesRGBGamma(pixel.blue); } SetPixelRed(image,ClampToQuantum((double) ScaleMapToQuantum(pixel.red)),q); @@ -3576,9 +3576,9 @@ static MagickBooleanType TransformsRGBImage(Image *image, } else { - pixel.red=sRGBCompandor(pixel.red); - pixel.green=sRGBCompandor(pixel.green); - pixel.blue=sRGBCompandor(pixel.blue); + pixel.red=EncodesRGBGamma(pixel.red); + pixel.green=EncodesRGBGamma(pixel.green); + pixel.blue=EncodesRGBGamma(pixel.blue); } image->colormap[i].red=(double) ClampToQuantum((double) ScaleMapToQuantum(pixel.red)); diff --git a/MagickCore/gem.c b/MagickCore/gem.c index 0d6ee4036..64608bc35 100644 --- a/MagickCore/gem.c +++ b/MagickCore/gem.c @@ -1012,61 +1012,3 @@ MagickPrivate size_t GetOptimalKernelWidth(const double radius, { return(GetOptimalKernelWidth1D(radius,sigma)); } - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % -% I n v e r s e s R G B C o m p a n d o r % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% InversesRGBCompandor() removes the gamma function from a sRGB pixel. -% -% The format of the InversesRGBCompandor method is: -% -% double InversesRGBCompandor(const double pixel) -% -% A description of each parameter follows: -% -% o pixel: the pixel. -% -*/ -MagickExport double InversesRGBCompandor(const double pixel) -{ - if (pixel <= (0.0404482362771076*QuantumRange)) - return(pixel/12.92); - return(QuantumRange*pow((QuantumScale*pixel+0.055)/1.055,2.4)); -} - -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% % -% s R G B C o m p a n d o r % -% % -% % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% sRGBCompandor() adds the gamma function to a sRGB pixel. -% -% The format of the sRGBCompandor method is: -% -% double sRGBCompandor(const double pixel) -% -% A description of each parameter follows: -% -% o pixel: the pixel. -% -*/ -MagickExport double sRGBCompandor(const double pixel) -{ - if (pixel <= (0.0031306684425005883*QuantumRange)) - return(12.92*pixel); - return(QuantumRange*(1.055*pow(QuantumScale*pixel,1.0/2.4)-0.055)); -} diff --git a/MagickCore/gem.h b/MagickCore/gem.h index 4fc348d9c..9dc8de612 100644 --- a/MagickCore/gem.h +++ b/MagickCore/gem.h @@ -26,9 +26,7 @@ extern "C" { #include extern MagickExport double - ExpandAffine(const AffineMatrix *), - InversesRGBCompandor(const double), - sRGBCompandor(const double); + ExpandAffine(const AffineMatrix *); extern MagickExport void ConvertHSLToRGB(const double,const double,const double,double *,double *, diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h index d8a490093..27cf23eb8 100644 --- a/MagickCore/pixel-accessor.h +++ b/MagickCore/pixel-accessor.h @@ -31,6 +31,20 @@ extern "C" { #undef index +static inline double DecodesRGBGamma(const double pixel) +{ + if (pixel <= (0.0404482362771076*QuantumRange)) + return(pixel/12.92); + return(QuantumRange*pow((QuantumScale*pixel+0.055)/1.055,2.4)); +} + +static inline double EncodesRGBGamma(const double pixel) +{ + if (pixel <= (0.0031306684425005883*QuantumRange)) + return(12.92*pixel); + return(QuantumRange*(1.055*pow(QuantumScale*pixel,1.0/2.4)-0.055)); +} + static inline Quantum GetPixela(const Image *restrict image, const Quantum *restrict pixel) { @@ -206,9 +220,9 @@ static inline double GetPixelInfoIntensity(const PixelInfo *restrict pixel_info) if (pixel_info->colorspace != sRGBColorspace) return(0.298839*pixel_info->red+0.586811*pixel_info->green+ 0.114350*pixel_info->blue); - red=InversesRGBCompandor(pixel_info->red); - green=InversesRGBCompandor(pixel_info->green); - blue=InversesRGBCompandor(pixel_info->blue); + red=DecodesRGBGamma(pixel_info->red); + green=DecodesRGBGamma(pixel_info->green); + blue=DecodesRGBGamma(pixel_info->blue); return(0.298839*red+0.586811*green+0.114350*blue); } @@ -224,9 +238,9 @@ static inline double GetPixelInfoLuminance(const PixelInfo *restrict pixel_info) if (pixel_info->colorspace != sRGBColorspace) return(0.21267*pixel_info->red+0.71516*pixel_info->green+ 0.07217*pixel_info->blue); - red=InversesRGBCompandor(pixel_info->red); - green=InversesRGBCompandor(pixel_info->green); - blue=InversesRGBCompandor(pixel_info->blue); + red=DecodesRGBGamma(pixel_info->red); + green=DecodesRGBGamma(pixel_info->green); + blue=DecodesRGBGamma(pixel_info->blue); return(0.21267*red+0.71516*green+0.07217*blue); } @@ -244,11 +258,11 @@ static inline double GetPixelIntensity(const Image *restrict image, return(0.298839*pixel[image->channel_map[RedPixelChannel].offset]+ 0.586811*pixel[image->channel_map[GreenPixelChannel].offset]+ 0.114350*pixel[image->channel_map[BluePixelChannel].offset]); - red=InversesRGBCompandor((double) + red=DecodesRGBGamma((double) pixel[image->channel_map[RedPixelChannel].offset]); - green=InversesRGBCompandor((double) + green=DecodesRGBGamma((double) pixel[image->channel_map[GreenPixelChannel].offset]); - blue=InversesRGBCompandor((double) + blue=DecodesRGBGamma((double) pixel[image->channel_map[BluePixelChannel].offset]); return(0.298839*red+0.586811*green+0.114350*blue); } @@ -273,11 +287,11 @@ static inline double GetPixelLuminance(const Image *restrict image, return(0.298839*pixel[image->channel_map[RedPixelChannel].offset]+ 0.586811*pixel[image->channel_map[GreenPixelChannel].offset]+ 0.114350*pixel[image->channel_map[BluePixelChannel].offset]); - red=InversesRGBCompandor((double) + red=DecodesRGBGamma((double) pixel[image->channel_map[RedPixelChannel].offset]); - green=InversesRGBCompandor((double) + green=DecodesRGBGamma((double) pixel[image->channel_map[GreenPixelChannel].offset]); - blue=InversesRGBCompandor((double) + blue=DecodesRGBGamma((double) pixel[image->channel_map[BluePixelChannel].offset]); return(0.21267*red+0.71516*green+0.07217*blue); } diff --git a/MagickCore/xwindow-private.h b/MagickCore/xwindow-private.h index b1c8b7d48..91a4ae3f8 100644 --- a/MagickCore/xwindow-private.h +++ b/MagickCore/xwindow-private.h @@ -603,9 +603,9 @@ static inline double XPixelIntensity(const XColor *pixel) green, red; - red=InversesRGBCompandor((double) pixel->red); - green=InversesRGBCompandor((double) pixel->green); - blue=InversesRGBCompandor((double) pixel->blue); + red=DecodesRGBGamma((double) pixel->red); + green=DecodesRGBGamma((double) pixel->green); + blue=DecodesRGBGamma((double) pixel->blue); return(0.298839*red+0.586811*green+0.114350*blue); }