]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 3 Apr 2010 02:25:17 +0000 (02:25 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 3 Apr 2010 02:25:17 +0000 (02:25 +0000)
Magick++/lib/Image.cpp
PerlMagick/Magick.xs
magick/deprecate.c
magick/morphology.c

index 5e3d8b84f26fe8a6a83048ac91a1ae767cfc61ce..71c699a5329ce94b630965b43f0d157cb4c7354b 100644 (file)
@@ -615,9 +615,6 @@ void Magick::Image::colorize ( const unsigned int opacity_,
 void Magick::Image::colorMatrix (const unsigned int order_,
          const double *color_matrix_)
 {
-  double
-    *values;
-
   KernelInfo
     *kernel_info;
 
@@ -626,11 +623,10 @@ void Magick::Image::colorMatrix (const unsigned int order_,
     kernel_info=AcquireKernelInfo("1");
   kernel_info->width=order_;
   kernel_info->height=order_;
-  values=kernel_info->values;
   kernel_info->values=(double *) color_matrix_;
   MagickCore::Image* newImage =
     ColorMatrixImage( image(), kernel_info, &exceptionInfo );
-  kernel_info->values=values;
+  kernel_info->values=(double *) NULL;
   kernel_info=DestroyKernelInfo(kernel_info);
   replaceImage( newImage );
   throwException( exceptionInfo );
index 2fb198dd832a27c32987a7266d7a861e79a0ca0b..ca2c05aa6116972802471273a4b3f846d982d1de 100644 (file)
@@ -528,7 +528,7 @@ static struct
     { "Morphology", { {"kernel", StringReference},
       {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
       {"iterations", IntegerReference} } },
-    { "ColorMatrix", { {"matrix", StringReference} } },
+    { "ColorMatrix", { {"matrix", ArrayReference} } },
   };
 
 static SplayTreeInfo
@@ -10457,16 +10457,42 @@ Mogrify(ref,...)
         case 108:  /* Recolor */
         case 134:  /* ColorMatrix */
         {
-          KernelInfo
+          AV
+            *av;
+
+          double
             *color_matrix;
 
+          KernelInfo
+            *kernel_info;
+
+          unsigned long
+            order;
+
           if (attribute_flag[0] == 0)
             break;
-          color_matrix=AcquireKernelInfo(argument_list[0].string_reference);
-          if (color_matrix == (KernelInfo *) NULL)
-            break;
-          image=ColorMatrixImage(image,color_matrix,exception);
-          color_matrix=DestroyKernelInfo(color_matrix);
+          av=(AV *) argument_list[0].array_reference;
+          order=(unsigned long) sqrt(av_len(av)+1);
+          color_matrix=(double *) AcquireQuantumMemory(order,order*
+            sizeof(*color_matrix));
+          if (color_matrix == (double *) NULL)
+            {
+              ThrowPerlException(exception,ResourceLimitFatalError,
+                "MemoryAllocationFailed",PackageName);
+              goto PerlException;
+           }
+          for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
+            color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
+          for ( ; j < (long) (order*order); j++)
+            color_matrix[j]=0.0;
+          kernel_info=AcquireKernelInfo((const char *) NULL);
+          kernel_info->width=order;
+          kernel_info->height=order;
+          kernel_info->values=color_matrix;
+          image=ColorMatrixImage(image,kernel_info,exception);
+          kernel_info->values=(double *) NULL;
+          kernel_info=DestroyKernelInfo(kernel_info);
+          color_matrix=(double *) RelinquishMagickMemory(color_matrix);
           break;
         }
       }
index 52df13097563431100fdf4bccdd5eb36b8ee28f5..bb91fdeff68a80812448485c19bd820e43c44516 100644 (file)
@@ -5232,22 +5232,18 @@ MagickExport void ReacquireMemory(void **memory,const size_t size)
 MagickExport Image *RecolorImage(const Image *image,const unsigned long order,
   const double *color_matrix,ExceptionInfo *exception)
 {
-  double
-    *values;
-
   KernelInfo
     *kernel_info;
 
   Image
     *recolor_image;
 
-  kernel_info=AcquireKernelInfo("1");
+  kernel_info=AcquireKernelInfo((const char *) NULL);
   kernel_info->width=order;
   kernel_info->height=order;
-  values=kernel_info->values;
   kernel_info->values=(double *) color_matrix;
   recolor_image=ColorMatrixImage(image,kernel_info,exception);
-  kernel_info->values=values;
+  kernel_info->values=(double *) NULL;
   kernel_info=DestroyKernelInfo(kernel_info);
   return(recolor_image);
 }
index 02118f7b674a8af5f964478412c512c3493ed694..3edf892d7c6fdbd9493abc8519460fc22ac65412 100644 (file)
@@ -202,12 +202,21 @@ MagickExport KernelInfo *AcquireKernelInfo(const char *kernel_string)
   double
     nan = sqrt((double)-1.0);  /* Special Value : Not A Number */
 
-  assert(kernel_string != (const char *) NULL);
+  if (kernel_string == (const char *) NULL)
+    {
+      kernel=(KernelInfo *) AcquireMagickMemory(sizeof(*kernel));
+      if (kernel == (KernelInfo *)NULL)
+        return(kernel);
+      (void) ResetMagickMemory(kernel,0,sizeof(*kernel));
+      kernel->type=UserDefinedKernel;
+      kernel->signature=MagickSignature;
+      return(kernel);
+    }
   SetGeometryInfo(&args);
 
   /* does it start with an alpha - Return a builtin kernel */
   GetMagickToken(kernel_string,&p,token);
-  if ( isalpha((int)token[0]) )
+  if (isalpha((int) ((unsigned char) *token)) != 0)
   {
     long
       type;