From 016ef8d9246b7e612d5c32647c14519ed612e2f0 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sat, 17 Feb 2018 14:37:56 +0100 Subject: [PATCH] Fixed setting the initial value for pixels in the write mask for image that had no alpha channel. --- MagickCore/image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MagickCore/image.c b/MagickCore/image.c index 16ee18280..d8a3021e0 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -2297,8 +2297,8 @@ MagickExport MagickBooleanType ResetImagePixels(Image *image, % % o image: the image. % -% o Alpha: the level of transparency: 0 is fully opaque and QuantumRange is -% fully transparent. +% o Alpha: the level of transparency: 0 is fully transparent and QuantumRange +% is fully opaque. % */ MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, @@ -2308,6 +2308,7 @@ MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, *image_view; MagickBooleanType + set_opaque, status; ssize_t @@ -2317,6 +2318,8 @@ MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(image->signature == MagickCoreSignature); + set_opaque=(image->alpha_trait == UndefinedPixelTrait) ? MagickTrue : + MagickFalse; image->alpha_trait=BlendPixelTrait; status=MagickTrue; image_view=AcquireAuthenticCacheView(image,exception); @@ -2344,6 +2347,8 @@ MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, { if (GetPixelWriteMask(image,q) > (QuantumRange/2)) SetPixelAlpha(image,alpha,q); + else if (set_opaque != MagickFalse) + SetPixelAlpha(image,OpaqueAlpha,q); q+=GetPixelChannels(image); } if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) -- 2.40.0