]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Mon, 3 Oct 2011 13:46:11 +0000 (13:46 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Mon, 3 Oct 2011 13:46:11 +0000 (13:46 +0000)
Magick++/lib/Image.cpp
MagickCore/color.c
MagickCore/fx.c
MagickCore/fx.h
MagickCore/magick-config.h
MagickCore/version.h
MagickWand/magick-image.c
MagickWand/mogrify.c
PerlMagick/Magick.xs
coders/msl.c

index 18aea6f970f15a059640e3088ba6b647a1a9c281..7e64bf072215154d889cbbe6a546f6d20462e74f 100644 (file)
@@ -600,14 +600,20 @@ void Magick::Image::colorize ( const unsigned int alphaRed_,
                            "Pen color argument is invalid");
   }
 
-  char alpha[MaxTextExtent];
-  FormatLocaleString(alpha,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,alphaBlue_);
+  char blend[MaxTextExtent];
+  FormatLocaleString(blend,MaxTextExtent,"%u/%u/%u",alphaRed_,alphaGreen_,alphaBlue_);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  PixelInfo target;
+  GetPixelInfo(image(),&target);
+  PixelPacket pixel=static_cast<PixelPacket>(penColor_);
+  target.red=pixel.red;
+  target.green=pixel.green;
+  target.blue=pixel.blue;
+  target.alpha=pixel.alpha;
   MagickCore::Image* newImage =
-  ColorizeImage ( image(), alpha,
-                 penColor_, &exceptionInfo );
+    ColorizeImage ( image(), blend, &target, &exceptionInfo );
   replaceImage( newImage );
   throwException( exceptionInfo );
   (void) DestroyExceptionInfo( &exceptionInfo );
index 83d9f1ddd5f784ab74b887682225d4fad16598b3..27d7a86ee4081d853519fa9fa946334b8cd4a496 100644 (file)
@@ -2256,8 +2256,7 @@ MagickExport MagickBooleanType QueryColorname(const Image *image,
 %
 */
 MagickExport MagickBooleanType QueryMagickColorCompliance(const char *name,
-  const ComplianceType compliance,PixelInfo *color,
-  ExceptionInfo *exception)
+  const ComplianceType compliance,PixelInfo *color,ExceptionInfo *exception)
 {
   GeometryInfo
     geometry_info;
index 55ab982e2009a960dcb3e1c24299620bf57d27cf..20eef6582f0f0bb8377b7d911921450c57eb1089 100644 (file)
@@ -674,14 +674,14 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
 %
 %  The format of the ColorizeImage method is:
 %
-%      Image *ColorizeImage(const Image *image,const char *opacity,
-%        const PixelPacket colorize,ExceptionInfo *exception)
+%      Image *ColorizeImage(const Image *image,const char *blend,
+%        const PixelInfo *colorize,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image: the image.
 %
-%    o opacity:  A character string indicating the level of opacity as a
+%    o blend:  A character string indicating the level of blending as a
 %      percentage.
 %
 %    o colorize: A color value.
@@ -689,8 +689,8 @@ MagickExport Image *CharcoalImage(const Image *image,const double radius,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
-  const PixelPacket colorize,ExceptionInfo *exception)
+MagickExport Image *ColorizeImage(const Image *image,const char *blend,
+  const PixelInfo *colorize,ExceptionInfo *exception)
 {
 #define ColorizeImageTag  "Colorize/Image"
 
@@ -710,12 +710,12 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
   MagickOffsetType
     progress;
 
-  PixelInfo
-    pixel;
-
   MagickStatusType
     flags;
 
+  PixelInfo
+    pixel;
+
   ssize_t
     y;
 
@@ -737,22 +737,31 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
       colorize_image=DestroyImage(colorize_image);
       return((Image *) NULL);
     }
-  if (opacity == (const char *) NULL)
+  if (blend == (const char *) NULL)
     return(colorize_image);
   /*
     Determine RGB values of the pen color.
   */
-  flags=ParseGeometry(opacity,&geometry_info);
+  flags=ParseGeometry(blend,&geometry_info);
+  GetPixelInfo(image,&pixel);
   pixel.red=geometry_info.rho;
   pixel.green=geometry_info.rho;
   pixel.blue=geometry_info.rho;
-  pixel.alpha=(MagickRealType) OpaqueAlpha;
+  pixel.alpha=100.0;
   if ((flags & SigmaValue) != 0)
     pixel.green=geometry_info.sigma;
   if ((flags & XiValue) != 0)
     pixel.blue=geometry_info.xi;
   if ((flags & PsiValue) != 0)
     pixel.alpha=geometry_info.psi;
+  if (pixel.colorspace == CMYKColorspace)
+    {
+      pixel.black=geometry_info.rho;
+      if ((flags & PsiValue) != 0)
+        pixel.black=geometry_info.psi;
+      if ((flags & ChiValue) != 0)
+        pixel.alpha=geometry_info.chi;
+    }
   /*
     Colorize DirectClass image.
   */
@@ -789,14 +798,68 @@ MagickExport Image *ColorizeImage(const Image *image,const char *opacity,
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      SetPixelRed(colorize_image,ClampToQuantum((GetPixelRed(image,p)*
-        (100.0-pixel.red)+colorize.red*pixel.red)/100.0),q);
-      SetPixelGreen(colorize_image,ClampToQuantum((GetPixelGreen(image,p)*
-        (100.0-pixel.green)+colorize.green*pixel.green)/100.0),q);
-      SetPixelBlue(colorize_image,ClampToQuantum((GetPixelBlue(image,p)*
-        (100.0-pixel.blue)+colorize.blue*pixel.blue)/100.0),q);
-      SetPixelAlpha(colorize_image,ClampToQuantum((GetPixelAlpha(image,p)*
-        (100.0-pixel.alpha)+colorize.alpha*pixel.alpha)/100.0),q);
+      register ssize_t
+        i;
+
+      for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+      {
+        PixelChannel
+          channel;
+
+        PixelTrait
+          colorize_traits,
+          traits;
+
+        traits=GetPixelChannelMapTraits(image,(PixelChannel) i);
+        channel=GetPixelChannelMapChannel(image,(PixelChannel) i);
+        colorize_traits=GetPixelChannelMapTraits(colorize_image,channel);
+        if ((traits == UndefinedPixelTrait) ||
+            (colorize_traits == UndefinedPixelTrait))
+          continue;
+        if ((colorize_traits & CopyPixelTrait) != 0)
+          {
+            SetPixelChannel(colorize_image,channel,p[i],q);
+            continue;
+          }
+        switch (channel)
+        {
+          case RedPixelChannel:
+          {
+            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
+              (100.0-pixel.red)+colorize->red*pixel.red)/100.0),q);
+            break;
+          }
+          case GreenPixelChannel:
+          {
+            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
+              (100.0-pixel.green)+colorize->green*pixel.green)/100.0),q);
+            break;
+          }
+          case BluePixelChannel:
+          {
+            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
+              (100.0-pixel.blue)+colorize->blue*pixel.blue)/100.0),q);
+            break;
+          }
+          case BlackPixelChannel:
+          {
+            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
+              (100.0-pixel.black)+colorize->black*pixel.black)/100.0),q);
+            break;
+          }
+          case AlphaPixelChannel:
+          {
+            SetPixelChannel(colorize_image,channel,ClampToQuantum((p[i]*
+              (100.0-pixel.alpha)+colorize->alpha*pixel.alpha)/100.0),q);
+            break;
+          }
+          default:
+          {
+            SetPixelChannel(colorize_image,channel,p[i],q);
+            break;
+          }
+        }
+      }
       p+=GetPixelChannels(image);
       q+=GetPixelChannels(colorize_image);
     }
index e3fb108325357be5f28a5d5e777cc1c3281a1916..c36bd8fa9c786dda9e47835a2717b3db7b10d3f4 100644 (file)
@@ -41,7 +41,7 @@ extern MagickExport Image
   *BlueShiftImage(const Image *,const double,ExceptionInfo *),
   *CharcoalImage(const Image *,const double,const double,const double,
     ExceptionInfo *),
-  *ColorizeImage(const Image *,const char *,const PixelPacket,ExceptionInfo *),
+  *ColorizeImage(const Image *,const char *,const PixelInfo *,ExceptionInfo *),
   *ColorMatrixImage(const Image *,const KernelInfo *kernel,ExceptionInfo *),
   *FxImage(const Image *,const char *,ExceptionInfo *),
   *ImplodeImage(const Image *,const double,const PixelInterpolateMethod,
index 6fe106710b0f3257f6aacd5f2b5b6a89056ac642..88c4ce4430a906e12ac95ccae46b45e34cb69605 100644 (file)
 #endif
 
 /* Define if you have the <lcms2.h> header file. */
-/* #undef HAVE_LCMS2_H */
+#ifndef MAGICKCORE_HAVE_LCMS2_H
+#define MAGICKCORE_HAVE_LCMS2_H 1
+#endif
 
 /* Define if you have the <lcms2/lcms2.h> header file. */
 /* #undef HAVE_LCMS2_LCMS2_H */
 
 /* Define if you have the <lcms.h> header file. */
-#ifndef MAGICKCORE_HAVE_LCMS_H
-#define MAGICKCORE_HAVE_LCMS_H 1
-#endif
+/* #undef HAVE_LCMS_H */
 
 /* Define if you have the <lcms/lcms.h> header file. */
 /* #undef HAVE_LCMS_LCMS_H */
 #endif
 
 /* Define if you have JBIG library */
-#ifndef MAGICKCORE_JBIG_DELEGATE
-#define MAGICKCORE_JBIG_DELEGATE 1
-#endif
+/* #undef JBIG_DELEGATE */
 
 /* Define if you have JPEG version 2 "Jasper" library */
 #ifndef MAGICKCORE_JP2_DELEGATE
 #endif
 
 /* Define if you have LQR library */
-#ifndef MAGICKCORE_LQR_DELEGATE
-#define MAGICKCORE_LQR_DELEGATE 1
-#endif
+/* #undef LQR_DELEGATE */
 
 /* Define if using libltdl to support dynamically loadable modules */
 #ifndef MAGICKCORE_LTDL_DELEGATE
 
 /* Define to the system default library search path. */
 #ifndef MAGICKCORE_LT_DLSEARCH_PATH
-#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/opt/intel/lib/intel64:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mysql:/usr/lib64/nvidia:/usr/lib64/qt-3.3/lib:/usr/lib64/xulrunner-2"
+#define MAGICKCORE_LT_DLSEARCH_PATH "/lib64:/usr/lib64:/lib:/usr/lib:/usr/lib64/R/lib:/usr/lib64/alliance/lib:/usr/lib64/atlas:/opt/modules/pkg/intel/f77/10.0.025/lib:/usr/lib64/kicad:/usr/lib/llvm:/usr/lib64/llvm:/usr/local/lib:/usr/lib64/mpich2/lib/:/usr/lib64/mysql:/usr/lib64/nvidia:/usr/lib64/octave/3.4.2:/usr/lib64/openmotif:/usr/lib64/qt-3.3/lib:/usr/lib64/tcl8.5/tclx8.4:/usr/lib/wine/:/usr/lib64/wine/:/usr/lib64/xulrunner-2"
 #endif
 
 /* The archive extension */
 
 
 /* Define if you have WEBP library */
-#ifndef MAGICKCORE_WEBP_DELEGATE
-#define MAGICKCORE_WEBP_DELEGATE 1
-#endif
+/* #undef WEBP_DELEGATE */
 
 /* Define to use the Windows GDI32 library */
 /* #undef WINGDI32_DELEGATE */
index fbaf355229935bd535a5dd9fb23ded5f98885c93..0e70512a2da8ff44bd6d4bc331b6307ddc66ce0d 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 #define MagickLibAddendum  "-0"
 #define MagickLibInterface  7
 #define MagickLibMinInterface  7
-#define MagickReleaseDate  "2011-10-02"
+#define MagickReleaseDate  "2011-10-03"
 #define MagickChangeDate   "20110801"
 #define MagickAuthoritativeURL  "http://www.imagemagick.org"
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
index afdc4df5e45c81872c33ea0c1607f14c0d08597e..9cfdd0b47e301fe0bd167f7321860e94e586c90c 100644 (file)
@@ -1434,7 +1434,7 @@ WandExport MagickBooleanType MagickColorDecisionListImage(MagickWand *wand,
 %  The format of the MagickColorizeImage method is:
 %
 %      MagickBooleanType MagickColorizeImage(MagickWand *wand,
-%        const PixelWand *colorize,const PixelWand *alpha)
+%        const PixelWand *colorize,const PixelWand *blend)
 %
 %  A description of each parameter follows:
 %
@@ -1446,31 +1446,49 @@ WandExport MagickBooleanType MagickColorDecisionListImage(MagickWand *wand,
 %
 */
 WandExport MagickBooleanType MagickColorizeImage(MagickWand *wand,
-  const PixelWand *colorize,const PixelWand *alpha)
+  const PixelWand *colorize,const PixelWand *blend)
 {
   char
-    percent_opaque[MaxTextExtent];
+    percent_blend[MaxTextExtent];
 
   Image
     *colorize_image;
 
-  PixelPacket
+  PixelInfo
     target;
 
+  Quantum
+    virtual_pixel[MaxPixelChannels];
+
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == WandSignature);
   if (wand->debug != MagickFalse)
     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
   if (wand->images == (Image *) NULL)
     ThrowWandException(WandError,"ContainsNoImages",wand->name);
-  (void) FormatLocaleString(percent_opaque,MaxTextExtent,
-    "%g,%g,%g,%g",(double) (100.0*QuantumScale*
-    PixelGetRedQuantum(alpha)),(double) (100.0*QuantumScale*
-    PixelGetGreenQuantum(alpha)),(double) (100.0*QuantumScale*
-    PixelGetBlueQuantum(alpha)),(double) (100.0*QuantumScale*
-    PixelGetAlphaQuantum(alpha)));
-  PixelGetQuantumPacket(colorize,&target);
-  colorize_image=ColorizeImage(wand->images,percent_opaque,target,
+  if (target.colorspace != CMYKColorspace)
+    (void) FormatLocaleString(percent_blend,MaxTextExtent,
+      "%g,%g,%g,%g",(double) (100.0*QuantumScale*
+      PixelGetRedQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetGreenQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetBlueQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetAlphaQuantum(blend)));
+  else
+    (void) FormatLocaleString(percent_blend,MaxTextExtent,
+      "%g,%g,%g,%g,%g",(double) (100.0*QuantumScale*
+      PixelGetRedQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetGreenQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetBlueQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetBlackQuantum(blend)),(double) (100.0*QuantumScale*
+      PixelGetAlphaQuantum(blend)));
+  PixelGetQuantumPixel(wand->images,colorize,virtual_pixel);
+  GetPixelInfo(wand->images,&target);
+  target.red=virtual_pixel[RedPixelChannel];
+  target.green=virtual_pixel[GreenPixelChannel];
+  target.blue=virtual_pixel[BluePixelChannel];
+  target.black=virtual_pixel[BlackPixelChannel];
+  target.alpha=virtual_pixel[AlphaPixelChannel];
+  colorize_image=ColorizeImage(wand->images,percent_blend,&target,
     wand->exception);
   if (colorize_image == (Image *) NULL)
     return(MagickFalse);
index e23d793c6de9e108199971b62373b26e31b2d0f7..abd6014595375fbb6a845cf602f877a95010bdaf 100644 (file)
@@ -1124,8 +1124,7 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
               Colorize the image.
             */
             (void) SyncImageSettings(mogrify_info,*image);
-            mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
-              exception);
+            mogrify_image=ColorizeImage(*image,argv[i+1],&fill,exception);
             break;
           }
         if (LocaleCompare("color-matrix",option+1) == 0)
index c78cb3537551c39445789319ab7318a253dfd837..91b0400d1b2a3d126913e2b6046d91015ffc4dda 100644 (file)
@@ -208,7 +208,7 @@ static struct
     { "Label", { {"label", StringReference} } },
     { "AddNoise", { {"noise", MagickNoiseOptions},
       {"channel", MagickChannelOptions} } },
-    { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
+    { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
     { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"fill", StringReference},
       {"bordercolor", StringReference}, {"color", StringReference},
@@ -7509,12 +7509,13 @@ Mogrify(ref,...)
         }
         case 4:  /* Colorize */
         {
-          PixelPacket
+          PixelInfo
             target;
 
           Quantum
             virtual_pixel[MaxPixelChannels];
 
+          GetPixelInfo(image,&target);
           (void) GetOneVirtualPixel(image,0,0,virtual_pixel,exception);
           target.red=virtual_pixel[RedPixelChannel];
           target.green=virtual_pixel[GreenPixelChannel];
@@ -7525,7 +7526,7 @@ Mogrify(ref,...)
               AllCompliance,&target,exception);
           if (attribute_flag[1] == 0)
             argument_list[1].string_reference="100%";
-          image=ColorizeImage(image,argument_list[1].string_reference,target,
+          image=ColorizeImage(image,argument_list[1].string_reference,&target,
             exception);
           break;
         }
index 6c43ab917ad02f9e7ce90c504526be5659940401..6fea30ea078097737d5a65b18dd346839d439895 100644 (file)
@@ -1367,12 +1367,12 @@ static void MSLStartElement(void *context,const xmlChar *tag,
       if (LocaleCompare((const char *) tag,"colorize") == 0)
         {
           char
-            opacity[MaxTextExtent];
+            blend[MaxTextExtent];
 
           Image
             *colorize_image;
 
-          PixelPacket
+          PixelInfo
             target;
 
           /*
@@ -1384,8 +1384,8 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 (const char *) tag);
               break;
             }
-          target=msl_info->image[n]->background_color;
-          (void) CopyMagickString(opacity,"100",MaxTextExtent);
+          GetPixelInfo(msl_info->image[n],&target);
+          (void) CopyMagickString(blend,"100",MaxTextExtent);
           if (attributes != (const xmlChar **) NULL)
             for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
             {
@@ -1396,25 +1396,25 @@ static void MSLStartElement(void *context,const xmlChar *tag,
               CloneString(&value,attribute);
               switch (*keyword)
               {
-                case 'F':
-                case 'f':
+                case 'B':
+                case 'b':
                 {
-                  if (LocaleCompare(keyword,"fill") == 0)
+                  if (LocaleCompare(keyword,"blend") == 0)
                     {
-                      (void) QueryColorCompliance(value,AllCompliance,&target,
-                        &msl_info->image[n]->exception);
+                      (void) CopyMagickString(blend,value,MaxTextExtent);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
                     keyword);
                   break;
                 }
-                case 'O':
-                case 'o':
+                case 'F':
+                case 'f':
                 {
-                  if (LocaleCompare(keyword,"opacity") == 0)
+                  if (LocaleCompare(keyword,"fill") == 0)
                     {
-                      (void) CopyMagickString(opacity,value,MaxTextExtent);
+                      (void) QueryMagickColorCompliance(value,AllCompliance,
+                        &target,&msl_info->image[n]->exception);
                       break;
                     }
                   ThrowMSLException(OptionError,"UnrecognizedAttribute",
@@ -1429,7 +1429,7 @@ static void MSLStartElement(void *context,const xmlChar *tag,
                 }
               }
             }
-          colorize_image=ColorizeImage(msl_info->image[n],opacity,target,
+          colorize_image=ColorizeImage(msl_info->image[n],blend,&target,
             &msl_info->image[n]->exception);
           if (colorize_image == (Image *) NULL)
             break;