From: cristy Date: Sun, 1 Jan 2012 20:49:11 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6474 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95f562af68c6bc67f4137b985c7d05c4eff4fdda;p=imagemagick --- diff --git a/MagickCore/paint.c b/MagickCore/paint.c index 73c074ac0..abfa4280a 100644 --- a/MagickCore/paint.c +++ b/MagickCore/paint.c @@ -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" @@ -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) diff --git a/MagickCore/pixel-accessor.h b/MagickCore/pixel-accessor.h index d1a5ee042..e61f65142 100644 --- a/MagickCore/pixel-accessor.h +++ b/MagickCore/pixel-accessor.h @@ -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 diff --git a/MagickCore/statistic.h b/MagickCore/statistic.h index 54909f4db..103e9b60c 100644 --- a/MagickCore/statistic.h +++ b/MagickCore/statistic.h @@ -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