From: cristy Date: Fri, 17 Aug 2012 13:12:15 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~5118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e83f340d3bcb446094ee1d63e02cc4f9d36c0db6;p=imagemagick --- diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 6441c76cb..7e9a72980 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -2728,8 +2728,8 @@ MagickExport MagickBooleanType LinearStretchImage(Image *image, % ModulateImage() lets you control the brightness, saturation, and hue % of an image. Modulate represents the brightness, saturation, and hue % as one parameter (e.g. 90,150,100). If the image colorspace is HSL, the -% modulation is lightness, saturation, and hue. And if the colorspace is -% HWB, use blackness, whiteness, and hue. +% modulation is lightness, saturation, and hue. For HWB, use blackness, +% whiteness, and hue. And for HCL, use chrome, luma, and hue. % % The format of the ModulateImage method is: % @@ -2746,7 +2746,30 @@ MagickExport MagickBooleanType LinearStretchImage(Image *image, % */ -static void ModulateHSB(const double percent_hue, +static inline void ModulateHCL(const double percent_hue, + const double percent_chroma,const double percent_luma,double *red, + double *green,double *blue) +{ + double + hue, + luma, + chroma; + + /* + Increase or decrease color luma, chroma, or hue. + */ + ConvertRGBToHCL(*red,*green,*blue,&hue,&chroma,&luma); + hue+=0.5*(0.01*percent_hue-1.0); + while (hue < 0.0) + hue+=1.0; + while (hue > 1.0) + hue-=1.0; + chroma*=0.01*percent_chroma; + luma*=0.01*percent_luma; + ConvertHCLToRGB(hue,chroma,luma,red,green,blue); +} + +static inline void ModulateHSB(const double percent_hue, const double percent_saturation,const double percent_brightness,double *red, double *green,double *blue) { @@ -2758,9 +2781,6 @@ static void ModulateHSB(const double percent_hue, /* Increase or decrease color brightness, saturation, or hue. */ - assert(red != (double *) NULL); - assert(green != (double *) NULL); - assert(blue != (double *) NULL); ConvertRGBToHSB(*red,*green,*blue,&hue,&saturation,&brightness); hue+=0.5*(0.01*percent_hue-1.0); while (hue < 0.0) @@ -2772,7 +2792,7 @@ static void ModulateHSB(const double percent_hue, ConvertHSBToRGB(hue,saturation,brightness,red,green,blue); } -static void ModulateHSL(const double percent_hue, +static inline void ModulateHSL(const double percent_hue, const double percent_saturation,const double percent_lightness,double *red, double *green,double *blue) { @@ -2784,9 +2804,6 @@ static void ModulateHSL(const double percent_hue, /* Increase or decrease color lightness, saturation, or hue. */ - assert(red != (double *) NULL); - assert(green != (double *) NULL); - assert(blue != (double *) NULL); ConvertRGBToHSL(*red,*green,*blue,&hue,&saturation,&lightness); hue+=0.5*(0.01*percent_hue-1.0); while (hue < 0.0) @@ -2798,7 +2815,9 @@ static void ModulateHSL(const double percent_hue, ConvertHSLToRGB(hue,saturation,lightness,red,green,blue); } -static void ModulateHWB(const double percent_hue,const double percent_whiteness, const double percent_blackness,double *red,double *green,double *blue) +static inline void ModulateHWB(const double percent_hue, + const double percent_whiteness,const double percent_blackness,double *red, + double *green,double *blue) { double blackness, @@ -2808,9 +2827,6 @@ static void ModulateHWB(const double percent_hue,const double percent_whiteness, /* Increase or decrease color blackness, whiteness, or hue. */ - assert(red != (double *) NULL); - assert(green != (double *) NULL); - assert(blue != (double *) NULL); ConvertRGBToHWB(*red,*green,*blue,&hue,&whiteness,&blackness); hue+=0.5*(0.01*percent_hue-1.0); while (hue < 0.0) @@ -2892,13 +2908,19 @@ MagickExport MagickBooleanType ModulateImage(Image *image,const char *modulate, red; /* - Modulate colormap. + Modulate colormap. */ red=image->colormap[i].red; green=image->colormap[i].green; blue=image->colormap[i].blue; switch (colorspace) { + case HCLColorspace: + { + ModulateHCL(percent_hue,percent_saturation,percent_brightness, + &red,&green,&blue); + break; + } case HSBColorspace: { ModulateHSB(percent_hue,percent_saturation,percent_brightness,