From c743d57edfa72dae1024835f39ee601d2d4fa385 Mon Sep 17 00:00:00 2001 From: Cristy Date: Thu, 10 Nov 2016 07:00:00 -0500 Subject: [PATCH] ... --- MagickCore/channel.c | 93 +++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/MagickCore/channel.c b/MagickCore/channel.c index b7fdd043d..402c61c4d 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -1082,56 +1082,13 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, return(status); } case CopyAlphaChannel: - case ShapeAlphaChannel: { /* Copy pixel intensity to the alpha channel. */ - image->alpha_trait=UpdatePixelTrait; + image->alpha_trait=BlendPixelTrait; status=CompositeImage(image,image,IntensityCompositeOp,MagickTrue,0,0, exception); - if (alpha_type == ShapeAlphaChannel) - { - PixelInfo - background; - - if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) - return(MagickFalse); - ConformPixelInfo(image,&image->background_color,&background, - exception); - /* - Set image background color. - */ - status=MagickTrue; - image_view=AcquireAuthenticCacheView(image,exception); - for (y=0; y < (ssize_t) image->rows; y++) - { - register Quantum - *magick_restrict q; - - register ssize_t - x; - - if (status == MagickFalse) - continue; - q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, - exception); - if (q == (Quantum *) NULL) - { - status=MagickFalse; - continue; - } - for (x=0; x < (ssize_t) image->columns; x++) - { - if (GetPixelAlpha(image,q) != TransparentAlpha) - SetPixelViaPixelInfo(image,&background,q); - q+=GetPixelChannels(image); - } - if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) - status=MagickFalse; - } - image_view=DestroyCacheView(image_view); - } break; } case DeactivateAlphaChannel: @@ -1290,6 +1247,54 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, status=SetImageAlpha(image,OpaqueAlpha,exception); break; } + case ShapeAlphaChannel: + { + PixelInfo + background; + + /* + Shape alpha channel. + */ + image->alpha_trait=BlendPixelTrait; + status=CompositeImage(image,image,IntensityCompositeOp,MagickTrue,0,0, + exception); + if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + return(MagickFalse); + ConformPixelInfo(image,&image->background_color,&background,exception); + /* + Set image background color. + */ + status=MagickTrue; + image_view=AcquireAuthenticCacheView(image,exception); + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (GetPixelAlpha(image,q) != TransparentAlpha) + SetPixelViaPixelInfo(image,&background,q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + } + image_view=DestroyCacheView(image_view); + break; + } case TransparentAlphaChannel: { status=SetImageAlpha(image,TransparentAlpha,exception); -- 2.40.0