]> granicus.if.org Git - imagemagick/commitdiff
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=30760
authorCristy <urban-warrior@imagemagick.org>
Wed, 9 Nov 2016 23:40:57 +0000 (18:40 -0500)
committerCristy <urban-warrior@imagemagick.org>
Wed, 9 Nov 2016 23:40:57 +0000 (18:40 -0500)
MagickCore/channel.c
MagickCore/enhance.c

index 38282e8d7860186dc4636211ad54579c74c71673..b7fdd043d778b7fe2f5443484c6e9900f6b8ee90 100644 (file)
@@ -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:
index 315cb24e45b05ca83cf3d01634a9721c826a4558..aa30f6143b4526aec9d111304eb6958b803afaba 100644 (file)
@@ -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)