]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Thu, 10 Nov 2016 12:00:00 +0000 (07:00 -0500)
committerCristy <urban-warrior@imagemagick.org>
Thu, 10 Nov 2016 12:00:00 +0000 (07:00 -0500)
MagickCore/channel.c

index b7fdd043d778b7fe2f5443484c6e9900f6b8ee90..402c61c4d0df9745244992236f7abca91ce79dc1 100644 (file)
@@ -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);