]> granicus.if.org Git - imagemagick/commitdiff
https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36396
authorCristy <urban-warrior@imagemagick.org>
Sat, 20 Jul 2019 13:24:36 +0000 (09:24 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 20 Jul 2019 20:22:43 +0000 (16:22 -0400)
ChangeLog
MagickCore/channel.c

index 0a3d8f9283eb6fffd2c0af932faf4d4c24eea9f4..2eb363e30ddfc2c278f6ca74d28483172dde8669 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-20  7.0.8-56 Cristy  <quetzlzacatenango@image...>
+  * Release ImageMagick version 7.0.8-56, GIT revision 15...
+
+2019-07-20  7.0.8-56 Cristy  <quetzlzacatenango@image...>
+  * Unexpected -alpha shape results (reference
+    https://imagemagick.org/discourse-server/viewtopic.php?f=3&t=36396).
+
 2019-07-18  7.0.8-55 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-55, GIT revision 15930:ac09240:20190718.
 
index 9737388f578d7f76321e536bcc8081b57085a3c4..043d142575dbefd229bcc0ae89866708d4a1f2fe 100644 (file)
@@ -1259,17 +1259,50 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
     }
     case ShapeAlphaChannel:
     {
+      PixelInfo
+        background;
+
       /*
-        Set alpha channel by shape.
+        Remove transparency.
       */
+      ConformPixelInfo(image,&image->background_color,&background,exception);
+      background.alpha_trait=BlendPixelTrait;
+      image->alpha_trait=BlendPixelTrait;
       status=SetImageStorageClass(image,DirectClass,exception);
       if (status == MagickFalse)
         break;
-      image->alpha_trait=UpdatePixelTrait;
-      (void) SetImageMask(image,WritePixelMask,image,exception);
-      (void) LevelImageColors(image,&image->background_color,
-        &image->background_color,MagickTrue,exception);
-      (void) SetImageMask(image,WritePixelMask,(Image *) NULL,exception);
+      image_view=AcquireAuthenticCacheView(image,exception);
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+      #pragma omp parallel for schedule(static) shared(status) \
+        magick_number_threads(image,image,image->rows,1)
+#endif
+      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++)
+        {
+          background.alpha=GetPixelIntensity(image,q);
+          SetPixelViaPixelInfo(image,&background,q);
+          q+=GetPixelChannels(image);
+        }
+        if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
+          status=MagickFalse;
+      }
+      image_view=DestroyCacheView(image_view);
       break;
     }
     case TransparentAlphaChannel: