]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 1 Jan 2012 20:49:11 +0000 (20:49 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 1 Jan 2012 20:49:11 +0000 (20:49 +0000)
MagickCore/paint.c
MagickCore/pixel-accessor.h
MagickCore/statistic.h

index 73c074ac0e0276e8166c2f0d5554432ee7b1a04b..abfa4280a924a2486f0841b06be744c2126ca59a 100644 (file)
@@ -55,6 +55,7 @@
 #include "MagickCore/monitor-private.h"
 #include "MagickCore/paint.h"
 #include "MagickCore/pixel-accessor.h"
+#include "MagickCore/statistic.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/thread-private.h"
 \f
@@ -175,10 +176,12 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
   /*
     Set floodfill state.
   */
-  floodplane_image=CloneImage(image,0,0,MagickTrue,exception);
+  floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
+    exception);
   if (floodplane_image == (Image *) NULL)
     return(MagickFalse);
-  (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel,exception);
+  floodplane_image->colorspace=GRAYColorspace;
+  (void) EvaluateImage(floodplane_image,SetEvaluateOperator,0.0,exception);
   segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
     sizeof(*segment_stack));
   if (segment_stack == (SegmentInfo *) NULL)
@@ -191,8 +194,6 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
     Push initial segment on stack.
   */
   status=MagickTrue;
-  fill_color.black=0.0;
-  fill_color.index=0.0;
   x=x_offset;
   y=y_offset;
   start=0;
@@ -233,12 +234,12 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
     q+=x1*GetPixelChannels(floodplane_image);
     for (x=x1; x >= 0; x--)
     {
-      if (GetPixelAlpha(floodplane_image,q) == TransparentAlpha)
+      if (GetPixelGray(floodplane_image,q) != 0)
         break;
       GetPixelInfoPixel(image,p,&pixel);
       if (IsFuzzyEquivalencePixelInfo(&pixel,target) == invert)
         break;
-      SetPixelAlpha(floodplane_image,TransparentAlpha,q);
+      SetPixelGray(floodplane_image,QuantumRange,q);
       p-=GetPixelChannels(image);
       q-=GetPixelChannels(floodplane_image);
     }
@@ -266,12 +267,12 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
                 break;
               for ( ; x < (ssize_t) image->columns; x++)
               {
-                if (GetPixelAlpha(floodplane_image,q) == TransparentAlpha)
+                if (GetPixelGray(floodplane_image,q) != 0)
                   break;
                 GetPixelInfoPixel(image,p,&pixel);
                 if (IsFuzzyEquivalencePixelInfo(&pixel,target) == invert)
                   break;
-                SetPixelAlpha(floodplane_image,TransparentAlpha,q);
+                SetPixelGray(floodplane_image,QuantumRange,q);
                 p+=GetPixelChannels(image);
                 q+=GetPixelChannels(floodplane_image);
               }
@@ -295,7 +296,7 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
             break;
           for ( ; x <= x2; x++)
           {
-            if (GetPixelAlpha(floodplane_image,q) == TransparentAlpha)
+            if (GetPixelGray(floodplane_image,q) != 0)
               break;
             GetPixelInfoPixel(image,p,&pixel);
             if (IsFuzzyEquivalencePixelInfo(&pixel,target) != invert)
@@ -321,14 +322,13 @@ MagickExport MagickBooleanType FloodfillPaintImage(Image *image,
     /*
       Tile fill color onto floodplane.
     */
-    p=GetCacheViewVirtualPixels(floodplane_view,0,y,image->columns,1,
-      exception);
+    p=GetCacheViewVirtualPixels(floodplane_view,0,y,image->columns,1,exception);
     q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
     if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
       break;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelAlpha(floodplane_image,p) != OpaqueAlpha)
+      if (GetPixelGray(floodplane_image,p) != 0)
         {
           (void) GetFillColor(draw_info,x,y,&fill_color,exception);
           SetPixelInfoPixel(image,&fill_color,q);
@@ -792,18 +792,7 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
     {
       GetPixelInfoPixel(image,q,&pixel);
       if (IsFuzzyEquivalencePixelInfo(&pixel,target) != invert)
-        {
-          if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
-            SetPixelRed(image,ClampToQuantum(fill->red),q);
-          if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
-            SetPixelGreen(image,ClampToQuantum(fill->green),q);
-          if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
-            SetPixelBlue(image,ClampToQuantum(fill->blue),q);
-          if ((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0)
-            SetPixelBlack(image,ClampToQuantum(fill->black),q);
-          if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
-            SetPixelAlpha(image,ClampToQuantum(fill->alpha),q);
-        }
+        SetPixelInfoPixel(image,fill,q);
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
index d1a5ee042a72d61538ece50764fc68d3a797a4ca..e61f65142927696689f502f63a639d103233e339 100644 (file)
@@ -193,6 +193,51 @@ static inline Quantum GetPixelInfoLuminance(
   return((Quantum) luminance);
 }
 
+static inline Quantum GetPixelIntensity(const Image *restrict image,
+  const Quantum *restrict pixel)
+{
+#if !defined(MAGICKCORE_HDRI_SUPPORT)
+  if ((pixel[image->channel_map[RedPixelChannel].offset] ==
+       pixel[image->channel_map[GreenPixelChannel].offset]) &&
+      (pixel[image->channel_map[GreenPixelChannel].offset] ==
+       pixel[image->channel_map[BluePixelChannel].offset]))
+    return(pixel[image->channel_map[RedPixelChannel].offset]);
+  return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
+    0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
+    pixel[image->channel_map[BluePixelChannel].offset]+0.5));
+#else
+  {
+    double
+      alpha,
+      beta;
+
+    alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
+      pixel[image->channel_map[GreenPixelChannel].offset];
+    beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
+      pixel[image->channel_map[BluePixelChannel].offset];
+    if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
+      return(pixel[image->channel_map[RedPixelChannel].offset]);
+    return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
+      0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
+      pixel[image->channel_map[BluePixelChannel].offset]));
+  }
+#endif
+}
+
+static inline Quantum GetPixelLuminance(const Image *restrict image,
+  const Quantum *restrict pixel)
+{
+#if !defined(MAGICKCORE_HDRI_SUPPORT)
+  return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
+    0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
+    pixel[image->channel_map[BluePixelChannel].offset]+0.5));
+#else
+  return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
+    0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
+    pixel[image->channel_map[BluePixelChannel].offset]));
+#endif
+}
+
 static inline Quantum GetPixelMagenta(const Image *restrict image,
   const Quantum *restrict pixel)
 {
@@ -624,51 +669,6 @@ static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
   image->channel_map[YPixelChannel].traits=traits;
 }
 
-static inline Quantum GetPixelIntensity(const Image *restrict image,
-  const Quantum *restrict pixel)
-{
-#if !defined(MAGICKCORE_HDRI_SUPPORT)
-  if ((pixel[image->channel_map[RedPixelChannel].offset] ==
-       pixel[image->channel_map[GreenPixelChannel].offset]) &&
-      (pixel[image->channel_map[GreenPixelChannel].offset] ==
-       pixel[image->channel_map[BluePixelChannel].offset]))
-    return(pixel[image->channel_map[RedPixelChannel].offset]);
-  return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
-    0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
-    pixel[image->channel_map[BluePixelChannel].offset]+0.5));
-#else
-  {
-    double
-      alpha,
-      beta;
-
-    alpha=pixel[image->channel_map[RedPixelChannel].offset]-(double)
-      pixel[image->channel_map[GreenPixelChannel].offset];
-    beta=pixel[image->channel_map[GreenPixelChannel].offset]-(double)
-      pixel[image->channel_map[BluePixelChannel].offset];
-    if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
-      return(pixel[image->channel_map[RedPixelChannel].offset]);
-    return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].offset]+
-      0.587*pixel[image->channel_map[GreenPixelChannel].offset]+0.114*
-      pixel[image->channel_map[BluePixelChannel].offset]));
-  }
-#endif
-}
-
-static inline Quantum GetPixelLuminance(const Image *restrict image,
-  const Quantum *restrict pixel)
-{
-#if !defined(MAGICKCORE_HDRI_SUPPORT)
-  return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
-    0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
-    pixel[image->channel_map[BluePixelChannel].offset]+0.5));
-#else
-  return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].offset]+
-    0.71516*pixel[image->channel_map[GreenPixelChannel].offset]+0.07217*
-    pixel[image->channel_map[BluePixelChannel].offset]));
-#endif
-}
-
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index 54909f4dbec628c1ad74a7ac165c1821cec11b91..103e9b60c45f2ea6a0670df1b0b7a52256249149 100644 (file)
@@ -44,36 +44,36 @@ typedef struct _ChannelStatistics
 typedef enum
 {
   UndefinedEvaluateOperator,
+  AbsEvaluateOperator,
   AddEvaluateOperator,
+  AddModulusEvaluateOperator,
   AndEvaluateOperator,
+  CosineEvaluateOperator,
   DivideEvaluateOperator,
+  ExponentialEvaluateOperator,
+  GaussianNoiseEvaluateOperator,
+  ImpulseNoiseEvaluateOperator,
+  LaplacianNoiseEvaluateOperator,
   LeftShiftEvaluateOperator,
+  LogEvaluateOperator,
   MaxEvaluateOperator,
+  MeanEvaluateOperator,
+  MedianEvaluateOperator,
   MinEvaluateOperator,
+  MultiplicativeNoiseEvaluateOperator,
   MultiplyEvaluateOperator,
   OrEvaluateOperator,
+  PoissonNoiseEvaluateOperator,
+  PowEvaluateOperator,
   RightShiftEvaluateOperator,
   SetEvaluateOperator,
+  SineEvaluateOperator,
   SubtractEvaluateOperator,
-  XorEvaluateOperator,
-  PowEvaluateOperator,
-  LogEvaluateOperator,
-  ThresholdEvaluateOperator,
   ThresholdBlackEvaluateOperator,
+  ThresholdEvaluateOperator,
   ThresholdWhiteEvaluateOperator,
-  GaussianNoiseEvaluateOperator,
-  ImpulseNoiseEvaluateOperator,
-  LaplacianNoiseEvaluateOperator,
-  MultiplicativeNoiseEvaluateOperator,
-  PoissonNoiseEvaluateOperator,
   UniformNoiseEvaluateOperator,
-  CosineEvaluateOperator,
-  SineEvaluateOperator,
-  AddModulusEvaluateOperator,
-  MeanEvaluateOperator,
-  AbsEvaluateOperator,
-  ExponentialEvaluateOperator,
-  MedianEvaluateOperator
+  XorEvaluateOperator
 } MagickEvaluateOperator;
 
 typedef enum