From: cristy Date: Sat, 4 Aug 2012 23:15:43 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~5191 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=722fc0cce634eb07588336accc3bb52979738a5c;p=imagemagick --- diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index fc39ce074..8eaf06ff6 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -421,6 +421,71 @@ static MagickBooleanType sRGBTransformImage(Image *image, image->type=GrayscaleType; return(status); } + case HCLColorspace: + { + /* + Transform image from sRGB to HCL. + */ + if (image->storage_class == PseudoClass) + { + if (SyncImage(image,exception) == MagickFalse) + return(MagickFalse); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + } + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) \ + dynamic_number_threads(image,image->columns,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + MagickBooleanType + sync; + + register ssize_t + x; + + register Quantum + *restrict q; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + double + blue, + chroma, + green, + hue, + luma, + red; + + red=QuantumRange*DecompandsRGB(QuantumScale*GetPixelRed(image,q)); + green=QuantumRange*DecompandsRGB(QuantumScale*GetPixelGreen(image,q)); + blue=QuantumRange*DecompandsRGB(QuantumScale*GetPixelBlue(image,q)); + ConvertRGBToHCL(red,green,blue,&hue,&chroma,&luma); + SetPixelRed(image,ClampToQuantum(QuantumRange*hue),q); + SetPixelGreen(image,ClampToQuantum(QuantumRange*chroma),q); + SetPixelBlue(image,ClampToQuantum(QuantumRange*luma),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + status=MagickFalse; + } + image_view=DestroyCacheView(image_view); + if (SetImageColorspace(image,colorspace,exception) == MagickFalse) + return(MagickFalse); + return(status); + } case HSBColorspace: { /* @@ -2155,6 +2220,74 @@ static MagickBooleanType TransformsRGBImage(Image *image, return(MagickFalse); return(status); } + case HCLColorspace: + { + /* + Transform image from HCL to sRGB. + */ + if (image->storage_class == PseudoClass) + { + if (SyncImage(image,exception) == MagickFalse) + return(MagickFalse); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + } + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) \ + dynamic_number_threads(image,image->columns,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + MagickBooleanType + sync; + + register ssize_t + x; + + register Quantum + *restrict q; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + double + blue, + chroma, + green, + hue, + luma, + red; + + hue=(double) (QuantumScale*GetPixelRed(image,q)); + chroma=(double) (QuantumScale*GetPixelGreen(image,q)); + luma=(double) (QuantumScale*GetPixelBlue(image,q)); + ConvertHCLToRGB(hue,chroma,luma,&red,&green,&blue); + red=QuantumRange*CompandsRGB(QuantumScale*red); + green=QuantumRange*CompandsRGB(QuantumScale*green); + blue=QuantumRange*CompandsRGB(QuantumScale*blue); + SetPixelRed(image,ClampToQuantum(red),q); + SetPixelGreen(image,ClampToQuantum(green),q); + SetPixelBlue(image,ClampToQuantum(blue),q); + q+=GetPixelChannels(image); + } + sync=SyncCacheViewAuthenticPixels(image_view,exception); + if (sync == MagickFalse) + status=MagickFalse; + } + image_view=DestroyCacheView(image_view); + if (SetImageColorspace(image,sRGBColorspace,exception) == MagickFalse) + return(MagickFalse); + return(status); + } case HSBColorspace: { /* diff --git a/MagickCore/colorspace.h b/MagickCore/colorspace.h index 3bade3b92..0442d8ae1 100644 --- a/MagickCore/colorspace.h +++ b/MagickCore/colorspace.h @@ -28,6 +28,7 @@ typedef enum CMYColorspace, CMYKColorspace, GRAYColorspace, + HCLColorspace, HSBColorspace, HSLColorspace, HWBColorspace, diff --git a/MagickCore/gem-private.h b/MagickCore/gem-private.h index 6c236bb3d..fce235107 100644 --- a/MagickCore/gem-private.h +++ b/MagickCore/gem-private.h @@ -32,10 +32,14 @@ extern MagickPrivate size_t GetOptimalKernelWidth2D(const double,const double); extern MagickPrivate void + ConvertHCLToRGB(const double,const double,const double,double *,double *, + double *), ConvertHSBToRGB(const double,const double,const double,double *,double *, double *), ConvertHWBToRGB(const double,const double,const double,double *,double *, double *), + ConvertRGBToHCL(const double,const double,const double,double *,double *, + double *), ConvertRGBToHSB(const double,const double,const double,double *,double *, double *), ConvertRGBToHWB(const double,const double,const double,double *,double *, diff --git a/MagickCore/gem.c b/MagickCore/gem.c index 00946e0fe..8d0e25870 100644 --- a/MagickCore/gem.c +++ b/MagickCore/gem.c @@ -63,6 +63,98 @@ % % % % % % +% C o n v e r t H C L T o R G B % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ConvertHCLToRGB() transforms a (hue, chroma, luma) to a (red, green, +% blue) triple. +% +% The format of the ConvertHCLToRGBImage method is: +% +% void ConvertHCLToRGB(const double hue,const double chroma, +% const double luma,double *red,double *green,double *blue) +% +% A description of each parameter follows: +% +% o hue, chroma, luma: A double value representing a +% component of the HCL color space. +% +% o red, green, blue: A pointer to a pixel component of type Quantum. +% +*/ +MagickPrivate void ConvertHCLToRGB(const double hue,const double chroma, + const double luma,double *red,double *green,double *blue) +{ + double + b, + c, + g, + h, + m, + r, + x; + + /* + Convert HCL to RGB colorspace. + */ + assert(red != (double *) NULL); + assert(green != (double *) NULL); + assert(blue != (double *) NULL); + h=6.0*hue; + c=chroma; + x=c*(1.0-fabs(fmod(h,2.0)-1.0)); + r=0.0; + g=0.0; + b=0.0; + if ((0.0 <= h) && (h < 1.0)) + { + r=c; + g=x; + } + else + if ((1.0 <= h) && (h < 2.0)) + { + r=x; + g=c; + } + else + if ((2.0 <= h) && (h < 3.0)) + { + g=c; + b=x; + } + else + if ((3.0 <= h) && (h < 4.0)) + { + g=x; + b=c; + } + else + if ((4.0 <= h) && (h < 5.0)) + { + r=x; + b=c; + } + else + if ((5.0 <= h) && (h < 6.0)) + { + r=c; + b=x; + } + m=luma-0.298839*r+0.586811*g+0.114350*b; + *red=QuantumRange*(r+m); + *green=QuantumRange*(g+m); + *blue=QuantumRange*(b+m); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % C o n v e r t H S B T o R G B % % % % % @@ -321,6 +413,73 @@ MagickPrivate void ConvertHWBToRGB(const double hue,const double whiteness, % % % % % % +% C o n v e r t R G B T o H C L % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ConvertRGBToHCL() transforms a (red, green, blue) to a (hue, chroma, +% luma) triple. +% +% The format of the ConvertRGBToHCL method is: +% +% void ConvertRGBToHCL(const double red,const double green, +% const double blue,double *hue,double *chroma,double *luma) +% +% A description of each parameter follows: +% +% o red, green, blue: A Quantum value representing the red, green, and +% blue component of a pixel. +% +% o hue, chroma, luma: A pointer to a double value representing a +% component of the HCL color space. +% +*/ +MagickPrivate void ConvertRGBToHCL(const double red,const double green, + const double blue,double *hue,double *chroma,double *luma) +{ + double + b, + c, + g, + h, + max, + r; + + /* + Convert RGB to HCL colorspace. + */ + assert(hue != (double *) NULL); + assert(chroma != (double *) NULL); + assert(luma != (double *) NULL); + r=red; + g=green; + b=blue; + max=MagickMax(r,MagickMax(g,b)); + c=max-(double) MagickMin(r,MagickMin(g,b)); + h=0.0; + if (c == 0) + h=0.0; + else + if (red == max) + h=fmod((g-b)/c,6.0); + else + if (green == max) + h=((b-r)/c)+2.0; + else + if (blue == max) + h=((r-g)/c)+4.0; + *hue=(h/6.0); + *chroma=QuantumScale*c; + *luma=QuantumScale*(0.298839*r+0.586811*g+0.114350*b); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % C o n v e r t R G B T o H S B % % % % % diff --git a/MagickCore/option.c b/MagickCore/option.c index 9b5283d83..17743788f 100644 --- a/MagickCore/option.c +++ b/MagickCore/option.c @@ -865,6 +865,7 @@ static const OptionInfo { "CMY", CMYColorspace, UndefinedOptionFlag, MagickFalse }, { "CMYK", CMYKColorspace, UndefinedOptionFlag, MagickFalse }, { "Gray", GRAYColorspace, UndefinedOptionFlag, MagickFalse }, + { "HCL", HCLColorspace, UndefinedOptionFlag, MagickFalse }, { "HSB", HSBColorspace, UndefinedOptionFlag, MagickFalse }, { "HSL", HSLColorspace, UndefinedOptionFlag, MagickFalse }, { "HWB", HWBColorspace, UndefinedOptionFlag, MagickFalse }, diff --git a/MagickCore/version.h b/MagickCore/version.h index 9b7d08fdf..6e09fef22 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -27,14 +27,14 @@ extern "C" { */ #define MagickPackageName "ImageMagick" #define MagickCopyright "Copyright (C) 1999-2012 ImageMagick Studio LLC" -#define MagickSVNRevision "8756" +#define MagickSVNRevision "8815M" #define MagickLibVersion 0x700 #define MagickLibVersionText "7.0.0" #define MagickLibVersionNumber 7,0,0 #define MagickLibAddendum "-0" #define MagickLibInterface 7 #define MagickLibMinInterface 7 -#define MagickReleaseDate "2012-07-29" +#define MagickReleaseDate "2012-08-04" #define MagickChangeDate "20110801" #define MagickAuthoritativeURL "http://www.imagemagick.org" #if defined(MAGICKCORE_OPENMP_SUPPORT) diff --git a/config/ImageMagick.rdf b/config/ImageMagick.rdf index 6aa2b3c3f..e62c7c8dd 100644 --- a/config/ImageMagick.rdf +++ b/config/ImageMagick.rdf @@ -5,7 +5,7 @@ ImageMagick ImageMagick: convert, edit, and compose images. - 2012-07-29 + 2012-08-04 ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. @@ -57,7 +57,7 @@ Examples of ImageMagick Usage shows how to use ImageMagick from the command-line stable - 2012-07-29 + 2012-08-04 7.0.0 -0 diff --git a/config/configure.xml b/config/configure.xml index 18b11797d..f9ca4ae7a 100644 --- a/config/configure.xml +++ b/config/configure.xml @@ -10,8 +10,8 @@ - - + +