From 476cf7aca8dc5ece6f964d6d27a46e9a6bbe35d0 Mon Sep 17 00:00:00 2001 From: Cristy Date: Wed, 9 Nov 2016 18:40:57 -0500 Subject: [PATCH] http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=30760 --- MagickCore/channel.c | 43 +++++++++++++++++++++++++++++++++++++++++-- MagickCore/enhance.c | 4 ++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/MagickCore/channel.c b/MagickCore/channel.c index 38282e8d7..b7fdd043d 100644 --- a/MagickCore/channel.c +++ b/MagickCore/channel.c @@ -1091,8 +1091,47 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image, status=CompositeImage(image,image,IntensityCompositeOp,MagickTrue,0,0, exception); if (alpha_type == ShapeAlphaChannel) - (void) LevelImageColors(image,&image->background_color, - &image->background_color,MagickTrue,exception); + { + 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: diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 315cb24e4..aa30f6143 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -2707,8 +2707,8 @@ MagickExport MagickBooleanType LevelImageColors(Image *image, if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); if ((IsGrayColorspace(image->colorspace) != MagickFalse) && - ((IsGrayColorspace(black_color->colorspace) == MagickFalse) || - (IsGrayColorspace(white_color->colorspace) == MagickFalse))) + ((IsGrayColorspace(black_color->colorspace) != MagickFalse) || + (IsGrayColorspace(white_color->colorspace) != MagickFalse))) (void) SetImageColorspace(image,sRGBColorspace,exception); status=MagickTrue; if (invert == MagickFalse) -- 2.40.0