#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
/*
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)
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;
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);
}
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);
}
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)
/*
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);
{
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)
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)
{
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
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