From 85d7a54de12dec3856774fa93a243bbc607f5403 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 13 May 2018 15:47:38 -0400 Subject: [PATCH] ... --- MagickCore/cache.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index b04317f4a..37b918384 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -3378,6 +3378,20 @@ MagickPrivate const Quantum *GetVirtualPixelsNexus(const Cache cache, % o exception: return any errors or warnings in this structure. % */ + +static inline Quantum ApplyPixelCompositeMask(const Quantum p, + const MagickRealType alpha,const Quantum q,const MagickRealType beta) +{ + double + mask_alpha; + + if (alpha == TransparentAlpha) + return(q); + mask_alpha=1.0-QuantumScale*QuantumScale*alpha*beta; + mask_alpha=PerceptibleReciprocal(mask_alpha); + return(mask_alpha*MagickOver_(p,alpha,q,beta)); +} + static MagickBooleanType MaskPixelCacheNexus(Image *image,NexusInfo *nexus_info, ExceptionInfo *exception) { @@ -3424,15 +3438,14 @@ static MagickBooleanType MaskPixelCacheNexus(Image *image,NexusInfo *nexus_info, if (p == (Quantum *) NULL) break; - mask_alpha=QuantumScale*GetPixelCompositeMask(image,p); + mask_alpha=GetPixelCompositeMask(image,p); for (i=0; i < (ssize_t) image->number_channels; i++) { PixelChannel channel = GetPixelChannelChannel(image,i); PixelTrait traits = GetPixelChannelTraits(image,channel); if ((traits & UpdatePixelTrait) == 0) continue; - q[i]=MagickOver_(p[i],mask_alpha*GetPixelAlpha(image,p),q[i], - GetPixelAlpha(image,q)); + q[i]=ApplyPixelCompositeMask(q[i],mask_alpha,p[i],GetPixelAlpha(image,p)); } p+=GetPixelChannels(image); q+=GetPixelChannels(image); -- 2.40.0