]> granicus.if.org Git - imagemagick/commitdiff
Introduce a composite mask
authorCristy <urban-warrior@imagemagick.org>
Sat, 12 May 2018 17:47:19 +0000 (13:47 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 12 May 2018 17:47:19 +0000 (13:47 -0400)
29 files changed:
MagickCore/accelerate.c
MagickCore/attribute.c
MagickCore/cache-private.h
MagickCore/cache.c
MagickCore/channel.c
MagickCore/compare.c
MagickCore/composite.c
MagickCore/decorate.c
MagickCore/draw.c
MagickCore/effect.c
MagickCore/enhance.c
MagickCore/fx.c
MagickCore/image.c
MagickCore/image.h
MagickCore/morphology.c
MagickCore/option.c
MagickCore/paint.c
MagickCore/pixel-accessor.h
MagickCore/pixel.c
MagickCore/pixel.h
MagickCore/quantum-export.c
MagickCore/quantum-import.c
MagickCore/resize.c
MagickCore/shear.c
MagickCore/statistic.c
MagickCore/threshold.c
MagickCore/transform.c
MagickWand/mogrify.c
MagickWand/operation.c

index 6286bd1e2feb11e587f960f7ccdc857a4f7edb9d..923926cdf4b3f3d18730f276277b555e199fe072 100644 (file)
@@ -123,8 +123,10 @@ static MagickBooleanType checkAccelerateCondition(const Image* image)
       (GetImageVirtualPixelMethod(image) != EdgeVirtualPixelMethod))
     return(MagickFalse);
 
-  /* check if the image has read / write mask */
-  if (image->read_mask != MagickFalse || image->write_mask != MagickFalse)
+  /* check if the image has mask */
+  if (image->composite_mask != MagickFalse ||
+      image->read_mask != MagickFalse ||
+      image->write_mask != MagickFalse)
     return(MagickFalse);
 
   if (image->number_channels > 4)
index e273ea9a9fb5ae38bffe65a713ee3675fed15d7c..432df00956fc33432c895028a2368418cc28b68d 100644 (file)
@@ -405,11 +405,6 @@ MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
           register ssize_t
             i;
 
-          if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-            {
-              p+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -465,11 +460,6 @@ MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
@@ -1094,11 +1084,6 @@ MagickExport MagickBooleanType SetImageDepth(Image *image,
           register ssize_t
             i;
 
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             PixelChannel
@@ -1158,11 +1143,6 @@ MagickExport MagickBooleanType SetImageDepth(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
index 9891543f0dc667759a05b23018e64bdc6f7e3690..58c488f90b0c1c096a0135d3a86268fb503a39eb 100644 (file)
@@ -224,6 +224,9 @@ typedef struct _CacheInfo
 
   MagickCLCacheInfo
     opencl;
+
+  MagickBooleanType
+    composite_mask;
 } CacheInfo;
 
 extern MagickPrivate Cache
index 5c19bca720efff0dee1399ca478a4e15cb237b24..b04317f4a9ee9c16ad4bf170076fd18970114fd4 100644 (file)
@@ -136,7 +136,8 @@ static Quantum
   *QueueAuthenticPixelsCache(Image *,const ssize_t,const ssize_t,const size_t,
     const size_t,ExceptionInfo *),
   *SetPixelCacheNexusPixels(const CacheInfo *,const MapMode,
-    const RectangleInfo *,NexusInfo *,ExceptionInfo *) magick_hot_spot;
+    const RectangleInfo *,const MagickBooleanType,NexusInfo *,
+    ExceptionInfo *) magick_hot_spot;
 
 #if defined(MAGICKCORE_OPENCL_SUPPORT)
 static void
@@ -205,6 +206,8 @@ MagickPrivate Cache AcquirePixelCache(const size_t number_threads)
   if (cache_info->number_threads == 0)
     cache_info->number_threads=1;
   cache_info->nexus_info=AcquirePixelCacheNexus(cache_info->number_threads);
+  if (cache_info->nexus_info == (NexusInfo **) NULL)
+    ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
   value=GetEnvironmentValue("MAGICK_SYNCHRONIZE");
   if (value != (const char *) NULL)
     {
@@ -376,6 +379,101 @@ MagickPrivate void CacheComponentTerminus(void)
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   C l i p P i x e l C a c h e N e x u s                                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ClipPixelCacheNexus() clips the cache nexus as defined by the image clip
+%  mask.  The method returns MagickTrue if the pixel region is clipped,
+%  otherwise MagickFalse.
+%
+%  The format of the ClipPixelCacheNexus() method is:
+%
+%      MagickBooleanType ClipPixelCacheNexus(Image *image,NexusInfo *nexus_info,
+%        ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o image: the image.
+%
+%    o nexus_info: the cache nexus to clip.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+static MagickBooleanType ClipPixelCacheNexus(Image *image,
+  NexusInfo *nexus_info,ExceptionInfo *exception)
+{
+  CacheInfo
+    *magick_restrict cache_info;
+
+  MagickSizeType
+    number_pixels;
+
+  NexusInfo
+    **magick_restrict image_nexus;
+
+  register Quantum
+    *magick_restrict p,
+    *magick_restrict q;
+
+  register ssize_t
+    n;
+
+  /*
+    Apply clip mask.
+  */
+  if (image->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  if (image->write_mask == MagickFalse)
+    return(MagickTrue);
+  cache_info=(CacheInfo *) image->cache;
+  if (cache_info == (Cache) NULL)
+    return(MagickFalse);
+  image_nexus=AcquirePixelCacheNexus(1);
+  p=GetAuthenticPixelCacheNexus(image,nexus_info->region.x,nexus_info->region.y,
+    nexus_info->region.width,nexus_info->region.height,image_nexus[0],
+    exception);
+  q=nexus_info->pixels;
+  number_pixels=(MagickSizeType) nexus_info->region.width*
+    nexus_info->region.height;
+  for (n=0; n < (ssize_t) number_pixels; n++)
+  {
+    double
+      mask_alpha;
+
+    register ssize_t
+      i;
+
+    if (p == (Quantum *) NULL)
+      break;
+    mask_alpha=QuantumScale*GetPixelWriteMask(image,p);
+    if (fabs(mask_alpha) >= MagickEpsilon)
+      for (i=0; i < (ssize_t) image->number_channels; i++)
+      {
+        PixelChannel channel = GetPixelChannelChannel(image,i);
+        PixelTrait traits = GetPixelChannelTraits(image,channel);
+        if ((traits & UpdatePixelTrait) == 0)
+          continue;
+        q[i]=MagickOver_(p[i],mask_alpha*GetPixelAlpha(image,p),q[i],
+          GetPixelAlpha(image,q));
+      }
+    p+=GetPixelChannels(image);
+    q+=GetPixelChannels(image);
+  }
+  image_nexus=DestroyPixelCacheNexus(image_nexus,1);
+  if (n < (ssize_t) number_pixels)
+    return(MagickFalse);
+  return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 +   C l o n e P i x e l C a c h e                                             %
 %                                                                             %
 %                                                                             %
@@ -628,7 +726,7 @@ static MagickBooleanType ClonePixelCacheRepository(
     region.height=1;
     region.x=0;
     region.y=y;
-    pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,
+    pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,MagickFalse,
       cache_nexus[id],exception);
     if (pixels == (Quantum *) NULL)
       continue;
@@ -636,7 +734,7 @@ static MagickBooleanType ClonePixelCacheRepository(
     if (status == MagickFalse)
       continue;
     region.width=clone_info->columns;
-    pixels=SetPixelCacheNexusPixels(clone_info,WriteMode,&region,
+    pixels=SetPixelCacheNexusPixels(clone_info,WriteMode,&region,MagickFalse,
       clone_nexus[id],exception);
     if (pixels == (Quantum *) NULL)
       continue;
@@ -714,7 +812,7 @@ static MagickBooleanType ClonePixelCacheRepository(
         region.height=1;
         region.x=0;
         region.y=y;
-        pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,
+        pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,MagickFalse,
           cache_nexus[id],exception);
         if (pixels == (Quantum *) NULL)
           continue;
@@ -723,7 +821,7 @@ static MagickBooleanType ClonePixelCacheRepository(
           continue;
         region.width=clone_info->columns;
         pixels=SetPixelCacheNexusPixels(clone_info,WriteMode,&region,
-          clone_nexus[id],exception);
+          MagickFalse,clone_nexus[id],exception);
         if (pixels == (Quantum *) NULL)
           continue;
         if ((clone_nexus[id]->metacontent != (void *) NULL) &&
@@ -1553,6 +1651,7 @@ static inline MagickBooleanType ValidatePixelCacheMorphology(
   if ((image->storage_class != cache_info->storage_class) ||
       (image->colorspace != cache_info->colorspace) ||
       (image->alpha_trait != cache_info->alpha_trait) ||
+      (image->composite_mask != cache_info->composite_mask) ||
       (image->read_mask != cache_info->read_mask) ||
       (image->write_mask != cache_info->write_mask) ||
       (image->columns != cache_info->columns) ||
@@ -1779,8 +1878,7 @@ MagickExport MagickBooleanType GetOneAuthenticPixel(Image *image,
   assert(cache_info->signature == MagickCoreSignature);
   (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
   if (cache_info->methods.get_one_authentic_pixel_from_handler != (GetOneAuthenticPixelFromHandler) NULL)
-    return(cache_info->methods.get_one_authentic_pixel_from_handler(image,x,y,
-      pixel,exception));
+    return(cache_info->methods.get_one_authentic_pixel_from_handler(image,x,y,pixel,exception));
   q=GetAuthenticPixelsCache(image,x,y,1UL,1UL,exception);
   return(CopyPixel(image,q,pixel));
 }
@@ -1889,7 +1987,8 @@ MagickExport MagickBooleanType GetOneVirtualPixel(const Image *image,
   cache_info=(CacheInfo *) image->cache;
   assert(cache_info->signature == MagickCoreSignature);
   (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
-  if (cache_info->methods.get_one_virtual_pixel_from_handler != (GetOneVirtualPixelFromHandler) NULL)
+  if (cache_info->methods.get_one_virtual_pixel_from_handler !=
+       (GetOneVirtualPixelFromHandler) NULL)
     return(cache_info->methods.get_one_virtual_pixel_from_handler(image,
       GetPixelCacheVirtualMethod(image),x,y,pixel,exception));
   assert(id < (int) cache_info->number_threads);
@@ -2665,8 +2764,8 @@ MagickPrivate const Quantum *GetVirtualPixelsFromNexus(const Image *image,
   region.y=y;
   region.width=columns;
   region.height=rows;
-  pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,nexus_info,
-    exception);
+  pixels=SetPixelCacheNexusPixels(cache_info,ReadMode,&region,image->write_mask,
+    nexus_info,exception);
   if (pixels == (Quantum *) NULL)
     return((const Quantum *) NULL);
   q=pixels;
@@ -3255,6 +3354,100 @@ MagickPrivate const Quantum *GetVirtualPixelsNexus(const Cache cache,
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   M a s k P i x e l C a c h e N e x u s                                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MaskPixelCacheNexus() masks the cache nexus as defined by the image mask.
+%  The method returns MagickTrue if the pixel region is masked, otherwise
+%  MagickFalse.
+%
+%  The format of the MaskPixelCacheNexus() method is:
+%
+%      MagickBooleanType MaskPixelCacheNexus(Image *image,
+%        NexusInfo *nexus_info,ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o image: the image.
+%
+%    o nexus_info: the cache nexus to clip.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+static MagickBooleanType MaskPixelCacheNexus(Image *image,NexusInfo *nexus_info,
+  ExceptionInfo *exception)
+{
+  CacheInfo
+    *magick_restrict cache_info;
+
+  MagickSizeType
+    number_pixels;
+
+  NexusInfo
+    **magick_restrict image_nexus;
+
+  register Quantum
+    *magick_restrict p,
+    *magick_restrict q;
+
+  register ssize_t
+    n;
+
+  /*
+    Apply clip mask.
+  */
+  if (image->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  if (image->composite_mask == MagickFalse)
+    return(MagickTrue);
+  cache_info=(CacheInfo *) image->cache;
+  if (cache_info == (Cache) NULL)
+    return(MagickFalse);
+  image_nexus=AcquirePixelCacheNexus(1);
+  p=GetAuthenticPixelCacheNexus(image,nexus_info->region.x,nexus_info->region.y,
+    nexus_info->region.width,nexus_info->region.height,image_nexus[0],
+    exception);
+  q=nexus_info->pixels;
+  number_pixels=(MagickSizeType) nexus_info->region.width*
+    nexus_info->region.height;
+  for (n=0; n < (ssize_t) number_pixels; n++)
+  {
+    double
+      mask_alpha;
+
+    register ssize_t
+      i;
+
+    if (p == (Quantum *) NULL)
+      break;
+    mask_alpha=QuantumScale*GetPixelCompositeMask(image,p);
+    for (i=0; i < (ssize_t) image->number_channels; i++)
+    {
+      PixelChannel channel = GetPixelChannelChannel(image,i);
+      PixelTrait traits = GetPixelChannelTraits(image,channel);
+      if ((traits & UpdatePixelTrait) == 0)
+        continue;
+      q[i]=MagickOver_(p[i],mask_alpha*GetPixelAlpha(image,p),q[i],
+        GetPixelAlpha(image,q));
+    }
+    p+=GetPixelChannels(image);
+    q+=GetPixelChannels(image);
+  }
+  image_nexus=DestroyPixelCacheNexus(image_nexus,1);
+  if (n < (ssize_t) number_pixels)
+    return(MagickFalse);
+  return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 +   O p e n P i x e l C a c h e                                               %
 %                                                                             %
 %                                                                             %
@@ -3486,6 +3679,7 @@ static MagickBooleanType OpenPixelCache(Image *image,const MapMode mode,
   cache_info->storage_class=image->storage_class;
   cache_info->colorspace=image->colorspace;
   cache_info->alpha_trait=image->alpha_trait;
+  cache_info->composite_mask=image->composite_mask;
   cache_info->read_mask=image->read_mask;
   cache_info->write_mask=image->write_mask;
   cache_info->rows=image->rows;
@@ -3856,6 +4050,7 @@ MagickExport MagickBooleanType PersistPixelCache(Image *image,
   clone_info->storage_class=cache_info->storage_class;
   clone_info->colorspace=cache_info->colorspace;
   clone_info->alpha_trait=cache_info->alpha_trait;
+  clone_info->composite_mask=cache_info->composite_mask;
   clone_info->read_mask=cache_info->read_mask;
   clone_info->write_mask=cache_info->write_mask;
   clone_info->columns=cache_info->columns;
@@ -3962,8 +4157,8 @@ MagickPrivate Quantum *QueueAuthenticPixelCacheNexus(Image *image,
   region.y=y;
   region.width=columns;
   region.height=rows;
-  pixels=SetPixelCacheNexusPixels(cache_info,WriteMode,&region,nexus_info,
-    exception);
+  pixels=SetPixelCacheNexusPixels(cache_info,WriteMode,&region,
+    image->write_mask,nexus_info,exception);
   return(pixels);
 }
 \f
@@ -4686,7 +4881,8 @@ MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods)
       cache_methods->get_authentic_metacontent_from_handler;
   get_one_virtual_pixel_from_handler=
     cache_info->methods.get_one_virtual_pixel_from_handler;
-  if (get_one_virtual_pixel_from_handler != (GetOneVirtualPixelFromHandler) NULL)
+  if (get_one_virtual_pixel_from_handler !=
+      (GetOneVirtualPixelFromHandler) NULL)
     cache_info->methods.get_one_virtual_pixel_from_handler=
       cache_methods->get_one_virtual_pixel_from_handler;
   get_one_authentic_pixel_from_handler=
@@ -4714,7 +4910,8 @@ MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods)
 %  The format of the SetPixelCacheNexusPixels() method is:
 %
 %      Quantum SetPixelCacheNexusPixels(const CacheInfo *cache_info,
-%        const MapMode mode,const RectangleInfo *region,NexusInfo *nexus_info,
+%        const MapMode mode,const RectangleInfo *region,
+%        const MagickBooleanType buffered,NexusInfo *nexus_info,
 %        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
@@ -4726,6 +4923,8 @@ MagickPrivate void SetPixelCacheMethods(Cache cache,CacheMethods *cache_methods)
 %    o region: A pointer to the RectangleInfo structure that defines the
 %      region of this particular cache nexus.
 %
+%    o buffered: if true, nexus pixels are buffered.
+%
 %    o nexus_info: the cache nexus to set.
 %
 %    o exception: return any errors or warnings in this structure.
@@ -4796,7 +4995,8 @@ static inline void PrefetchPixelCacheNexusPixels(const NexusInfo *nexus_info,
 }
 
 static Quantum *SetPixelCacheNexusPixels(const CacheInfo *cache_info,
-  const MapMode mode,const RectangleInfo *region,NexusInfo *nexus_info,
+  const MapMode mode,const RectangleInfo *region,
+  const MagickBooleanType buffered,NexusInfo *nexus_info,
   ExceptionInfo *exception)
 {
   MagickBooleanType
@@ -4817,7 +5017,8 @@ static Quantum *SetPixelCacheNexusPixels(const CacheInfo *cache_info,
     nexus_info->region.height;
   if (number_pixels == 0)
     return((Quantum *) NULL);
-  if ((cache_info->type == MemoryCache) || (cache_info->type == MapCache))
+  if (((cache_info->type == MemoryCache) || (cache_info->type == MapCache)) &&
+      (buffered == MagickFalse))
     {
       ssize_t
         x,
@@ -5119,6 +5320,12 @@ MagickPrivate MagickBooleanType SyncAuthenticPixelCacheNexus(Image *image,
   assert(cache_info->signature == MagickCoreSignature);
   if (cache_info->type == UndefinedCache)
     return(MagickFalse);
+  if ((image->write_mask != MagickFalse) &&
+      (ClipPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
+    return(MagickFalse);
+  if ((image->composite_mask != MagickFalse) &&
+      (MaskPixelCacheNexus(image,nexus_info,exception) == MagickFalse))
+    return(MagickFalse);
   if (nexus_info->authentic_pixel_cache != MagickFalse)
     {
       image->taint=MagickTrue;
index 4a000991509102b3e3d82f9c218cd8afe78a0e62..a5955833f10e74d4ac18f70e4193595dc0115101 100644 (file)
@@ -772,13 +772,6 @@ MagickExport Image *SeparateImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(separate_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(separate_image);
-          continue;
-        }
       SetPixelChannel(separate_image,GrayPixelChannel,0,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
@@ -1026,11 +1019,6 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
           register ssize_t
             i;
 
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           gamma=QuantumScale*GetPixelAlpha(image,q);
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
@@ -1152,11 +1140,6 @@ MagickExport MagickBooleanType SetImageAlphaChannel(Image *image,
           register ssize_t
             i;
 
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           Sa=QuantumScale*GetPixelAlpha(image,q);
           gamma=PerceptibleReciprocal(Sa);
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
index 733dd37094fc93fee1209242a05705902c2ee9aa..849d32059b0d598e09169cf897b91520ee714c80 100644 (file)
@@ -430,12 +430,6 @@ static MagickBooleanType GetAbsoluteDistortion(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(reconstruct_image);
-          continue;
-        }
       difference=MagickFalse;
       distance=0.0;
       Sa=QuantumScale*GetPixelAlpha(image,p);
@@ -1919,12 +1913,6 @@ MagickExport MagickBooleanType IsImagesEqual(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(reconstruct_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         double
@@ -2058,12 +2046,6 @@ MagickExport MagickBooleanType SetImageColorMetric(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(reconstruct_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         double
@@ -2276,12 +2258,6 @@ MagickExport Image *SimilarityImage(const Image *image,const Image *reference,
         }
       if (metric == PerceptualHashErrorMetric)
         similarity=MagickMin(0.01*similarity,1.0);
-      if (GetPixelWriteMask(similarity_image,q) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(similarity_image,q);
-          q+=GetPixelChannels(similarity_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index 2aef32a0d01e126a6d62358df24a0fb5e775d1d9..6142450ead430c4f1440866ca052741309e2042c 100644 (file)
@@ -420,11 +420,6 @@ static MagickBooleanType CompositeOverImage(Image *image,
           */
           (void) GetOneVirtualPixel(source_image,x-x_offset,y-y_offset,source,
             exception);
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             MagickRealType
@@ -455,12 +450,6 @@ static MagickBooleanType CompositeOverImage(Image *image,
       Sa=QuantumScale*GetPixelAlpha(source_image,p);
       Da=QuantumScale*GetPixelAlpha(image,q);
       alpha=Sa+Da-Sa*Da;
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(source_image);
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         MagickRealType
@@ -1347,11 +1336,6 @@ MagickExport MagickBooleanType CompositeImage(Image *image,
           */
           (void) GetOneVirtualPixel(source_image,x-x_offset,y-y_offset,source,
             exception);
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             MagickRealType
@@ -1506,12 +1490,6 @@ MagickExport MagickBooleanType CompositeImage(Image *image,
           break;
         }
       }
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(source_image);
-          q+=GetPixelChannels(image);
-          continue;
-        }
       switch (compose)
       {
         case ColorizeCompositeOp:
@@ -2521,12 +2499,6 @@ MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture,
         register ssize_t
           i;
 
-        if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-          {
-            p+=GetPixelChannels(texture_image);
-            q+=GetPixelChannels(image);
-            continue;
-          }
         for (i=0; i < (ssize_t) GetPixelChannels(texture_image); i++)
         {
           PixelChannel channel = GetPixelChannelChannel(texture_image,i);
index 93b49dcf94192565807f48a402ed7eb06571333c..cbc48ee1e27aa652b4acd9d5f9208ab2f3c26494 100644 (file)
@@ -679,11 +679,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
       }
     for (x=0; x < y; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -697,11 +692,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
     }
     for ( ; x < (ssize_t) (image->columns-y); x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -715,11 +705,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
     }
     for ( ; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -769,11 +754,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
       }
     for (x=0; x < (ssize_t) raise_info->width; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -789,11 +769,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
       q+=GetPixelChannels(image);
     for ( ; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -843,11 +818,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
       }
     for (x=0; x < (ssize_t) (image->rows-y); x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -874,11 +844,6 @@ MagickExport MagickBooleanType RaiseImage(Image *image,
     }
     for ( ; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index fd791f6e35fea01bb08946787525642305079853..d5f3ca9ba5dccacd40ed5cded59353b58b725b7c 100644 (file)
@@ -1489,7 +1489,8 @@ static Image *DrawClippingMask(Image *image,const DrawInfo *draw_info,
   const char *id,const char *clip_path,ExceptionInfo *exception)
 {
   Image
-    *clip_mask;
+    *clip_mask,
+    *separate_mask;
 
   DrawInfo
     *clone_info;
@@ -1530,11 +1531,16 @@ static Image *DrawClippingMask(Image *image,const DrawInfo *draw_info,
   clone_info->alpha=OpaqueAlpha;
   clone_info->clip_path=MagickTrue;
   status=DrawImage(clip_mask,clone_info,exception);
-  (void) CompositeImage(clip_mask,clip_mask,AlphaCompositeOp,MagickTrue,0,0,
-    exception);
   clone_info=DestroyDrawInfo(clone_info);
-  if (status == MagickFalse)
-    clip_mask=DestroyImage(clip_mask);
+  separate_mask=SeparateImage(clip_mask,AlphaChannel,exception);
+  if (separate_mask != (Image *) NULL)
+    {
+      clip_mask=DestroyImage(clip_mask);
+      clip_mask=separate_mask;
+      status=NegateImage(clip_mask,MagickFalse,exception);
+      if (status == MagickFalse)
+        clip_mask=DestroyImage(clip_mask);
+    }
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end clip-path");
   return(clip_mask);
@@ -1575,7 +1581,8 @@ static Image *DrawCompositeMask(Image *image,const DrawInfo *draw_info,
   const char *id,const char *mask_path,ExceptionInfo *exception)
 {
   Image
-    *composite_mask;
+    *composite_mask,
+    *separate_mask;
 
   DrawInfo
     *clone_info;
@@ -1595,8 +1602,8 @@ static Image *DrawCompositeMask(Image *image,const DrawInfo *draw_info,
     exception);
   if (composite_mask == (Image *) NULL)
     return((Image *) NULL);
-  (void) SetImageMask(composite_mask,ReadPixelMask,(Image *) NULL,exception);
-  (void) SetImageMask(composite_mask,WritePixelMask,(Image *) NULL,exception);
+  (void) SetImageMask(composite_mask,CompositePixelMask,(Image *) NULL,
+    exception);
   (void) QueryColorCompliance("#0000",AllCompliance,
     &composite_mask->background_color,exception);
   composite_mask->background_color.alpha=(MagickRealType) TransparentAlpha;
@@ -1614,11 +1621,16 @@ static Image *DrawCompositeMask(Image *image,const DrawInfo *draw_info,
   clone_info->stroke_width=0.0;
   clone_info->alpha=OpaqueAlpha;
   status=DrawImage(composite_mask,clone_info,exception);
-  (void) CompositeImage(composite_mask,composite_mask,AlphaCompositeOp,
-    MagickTrue,0,0,exception);
   clone_info=DestroyDrawInfo(clone_info);
-  if (status == MagickFalse)
-    composite_mask=DestroyImage(composite_mask);
+  separate_mask=SeparateImage(composite_mask,AlphaChannel,exception);
+  if (separate_mask != (Image *) NULL)
+    {
+      composite_mask=DestroyImage(composite_mask);
+      composite_mask=separate_mask;
+      status=NegateImage(composite_mask,MagickFalse,exception);
+      if (status == MagickFalse)
+        composite_mask=DestroyImage(composite_mask);
+    }
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"end mask-path");
   return(composite_mask);
@@ -1989,11 +2001,6 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
       offset*=PerceptibleReciprocal(length);
     for (x=bounding_box.x; x < (ssize_t) bounding_box.width; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       GetPixelInfoPixel(image,q,&pixel);
       switch (gradient->spread)
       {
@@ -2935,7 +2942,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
                   graphic_context[n],token,mask_path,exception);
                 mask_path=DestroyString(mask_path);
                 if (draw_info->compliance != SVGCompliance)
-                  status=SetImageMask(image,WritePixelMask,
+                  status=SetImageMask(image,CompositePixelMask,
                     graphic_context[n]->composite_mask,exception);
               }
             break;
@@ -3896,16 +3903,6 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
             status=MagickFalse;
             break;
           }
-        if ((primitive_info[j+1].point.x-primitive_info[j].point.x) < 0.0)
-          {
-            status=MagickFalse;
-            break;
-          }
-        if ((primitive_info[j+1].point.y-primitive_info[j].point.y) < 0.0)
-          {
-            status=MagickFalse;
-            break;
-          }
         TraceRectangle(primitive_info+j,primitive_info[j].point,
           primitive_info[j+1].point);
         i=(ssize_t) (j+primitive_info[j].coordinates);
@@ -4672,7 +4669,6 @@ RestoreMSCWarning
     {
       double
         fill_alpha,
-        mask_alpha,
         stroke_alpha;
 
       PixelInfo
@@ -4689,13 +4685,12 @@ RestoreMSCWarning
           fill_alpha=fill_alpha > 0.25 ? 1.0 : 0.0;
           stroke_alpha=stroke_alpha > 0.25 ? 1.0 : 0.0;
         }
-      mask_alpha=QuantumScale*GetPixelWriteMask(image,q);
       GetFillColor(draw_info,x-start_x,y-start_y,&fill_color,exception);
-      CompositePixelOver(image,&fill_color,mask_alpha*fill_alpha*
-        fill_color.alpha,q,(double) GetPixelAlpha(image,q),q);
+      CompositePixelOver(image,&fill_color,fill_alpha*fill_color.alpha,q,
+        (double) GetPixelAlpha(image,q),q);
       GetStrokeColor(draw_info,x-start_x,y-start_y,&stroke_color,exception);
-      CompositePixelOver(image,&stroke_color,mask_alpha*stroke_alpha*
-        stroke_color.alpha,q,(double) GetPixelAlpha(image,q),q);
+      CompositePixelOver(image,&stroke_color,stroke_alpha*stroke_color.alpha,q,
+        (double) GetPixelAlpha(image,q),q);
       q+=GetPixelChannels(image);
     }
     if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
@@ -4872,8 +4867,12 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
     (void) SetImageColorspace(image,sRGBColorspace,exception);
   status=MagickTrue;
   if (draw_info->compliance == SVGCompliance)
-    status=SetImageMask(image,WritePixelMask,draw_info->clipping_mask,
-      exception);
+    {
+      status=SetImageMask(image,WritePixelMask,draw_info->clipping_mask,
+        exception);
+      status&=SetImageMask(image,CompositePixelMask,draw_info->composite_mask,
+        exception);
+    }
   x=(ssize_t) ceil(primitive_info->point.x-0.5);
   y=(ssize_t) ceil(primitive_info->point.y-0.5);
   image_view=AcquireAuthenticCacheView(image,exception);
@@ -4925,11 +4924,6 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-                {
-                  q+=GetPixelChannels(image);
-                  continue;
-                }
               GetPixelInfoPixel(image,q,&pixel);
               if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)
                 {
@@ -4989,11 +4983,6 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-                {
-                  q+=GetPixelChannels(image);
-                  continue;
-                }
               GetFillColor(draw_info,x,y,&pixel,exception);
               SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
               q+=GetPixelChannels(image);
@@ -5051,11 +5040,6 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-                {
-                  q+=GetPixelChannels(image);
-                  continue;
-                }
               GetPixelInfoPixel(image,q,&pixel);
               if (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)
                 {
@@ -5111,11 +5095,6 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
               break;
             for (x=0; x < (ssize_t) image->columns; x++)
             {
-              if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-                {
-                  q+=GetPixelChannels(image);
-                  continue;
-                }
               GetFillColor(draw_info,x,y,&pixel,exception);
               SetPixelViaPixelInfo(image,&pixel,q);
               q+=GetPixelChannels(image);
@@ -5309,7 +5288,10 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
   }
   image_view=DestroyCacheView(image_view);
   if (draw_info->compliance == SVGCompliance)
-    status&=SetImageMask(image,WritePixelMask,(Image *) NULL,exception);
+    {
+      status&=SetImageMask(image,WritePixelMask,(Image *) NULL,exception);
+      status&=SetImageMask(image,CompositePixelMask,(Image *) NULL,exception);
+    }
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(DrawEvent,GetMagickModule(),"  end draw-primitive");
   return(status != 0 ? MagickTrue : MagickFalse);
@@ -6231,7 +6213,7 @@ static size_t TracePath(PrimitiveInfo *primitive_info,const char *path,
         do
         {
           GetNextToken(p,&p,MagickPathExtent,token);
-          if (*token == ',')
+          if ((i != 0) && (*token == ','))
             GetNextToken(p,&p,MagickPathExtent,token);
           x=StringToDouble(token,&next_token);
           if (token == next_token)
index ca20e6d8b208e8adaec4f80b22343f9928ff7bc5..d336650082e03085d51b11a62ca45e44689fb7ec 100644 (file)
@@ -335,8 +335,7 @@ MagickExport Image *AdaptiveBlurImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (blur_traits == UndefinedPixelTrait))
           continue;
-        if (((blur_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((blur_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(blur_image,channel,p[center+i],q);
             continue;
@@ -656,8 +655,7 @@ MagickExport Image *AdaptiveSharpenImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (sharp_traits == UndefinedPixelTrait))
           continue;
-        if (((sharp_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((sharp_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(sharp_image,channel,p[center+i],q);
             continue;
@@ -2155,8 +2153,7 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (blur_traits == UndefinedPixelTrait))
           continue;
-        if (((blur_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((blur_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(blur_image,channel,p[i],q);
             continue;
@@ -2961,8 +2958,7 @@ MagickExport Image *RotationalBlurImage(const Image *image,const double angle,
         if ((traits == UndefinedPixelTrait) ||
             (blur_traits == UndefinedPixelTrait))
           continue;
-        if (((blur_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((blur_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(blur_image,channel,p[i],q);
             continue;
@@ -3276,8 +3272,7 @@ MagickExport Image *SelectiveBlurImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (blur_traits == UndefinedPixelTrait))
           continue;
-        if (((blur_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((blur_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(blur_image,channel,p[center+i],q);
             continue;
@@ -3568,8 +3563,7 @@ MagickExport Image *ShadeImage(const Image *image,const MagickBooleanType gray,
         if ((traits == UndefinedPixelTrait) ||
             (shade_traits == UndefinedPixelTrait))
           continue;
-        if (((shade_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(linear_image,center) <= (QuantumRange/2)))
+        if ((shade_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(shade_image,channel,center[i],q);
             continue;
@@ -4011,8 +4005,7 @@ MagickExport Image *UnsharpMaskImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (unsharp_traits == UndefinedPixelTrait))
           continue;
-        if (((unsharp_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((unsharp_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(unsharp_image,channel,p[i],q);
             continue;
index 995a50c97c484aa38f54c270bcf63a182ac77c03..4689ca6755ee337e9d6d7f71ea74c4915ecdbd9e 100644 (file)
@@ -382,11 +382,6 @@ MagickExport MagickBooleanType ClutImage(Image *image,const Image *clut_image,
       PixelTrait
         traits;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       GetPixelInfoPixel(image,q,&pixel);
       traits=GetPixelChannelTraits(image,RedPixelChannel);
       if ((traits & UpdatePixelTrait) != 0)
@@ -1237,11 +1232,6 @@ MagickExport MagickBooleanType ContrastStretchImage(Image *image,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -1421,13 +1411,6 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
       register const Quantum
         *magick_restrict r;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(enhance_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(enhance_image);
-          continue;
-        }
       GetPixelInfo(image,&aggregate);
       total_weight=0.0;
       GetPixelInfoPixel(image,p+center,&pixel);
@@ -1712,11 +1695,6 @@ MagickExport MagickBooleanType EqualizeImage(Image *image,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -1894,11 +1872,6 @@ MagickExport MagickBooleanType GammaImage(Image *image,const double gamma,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -2036,11 +2009,6 @@ MagickExport MagickBooleanType GrayscaleImage(Image *image,
         red,
         intensity;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       red=(MagickRealType) GetPixelRed(image,q);
       green=(MagickRealType) GetPixelGreen(image,q);
       blue=(MagickRealType) GetPixelBlue(image,q);
@@ -2481,11 +2449,6 @@ MagickExport MagickBooleanType LevelImage(Image *image,const double black_point,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -2637,11 +2600,6 @@ MagickExport MagickBooleanType LevelizeImage(Image *image,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -3304,11 +3262,6 @@ MagickExport MagickBooleanType ModulateImage(Image *image,const char *modulate,
         green,
         red;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       red=(double) GetPixelRed(image,q);
       green=(double) GetPixelGreen(image,q);
       blue=(double) GetPixelBlue(image,q);
@@ -3491,8 +3444,7 @@ MagickExport MagickBooleanType NegateImage(Image *image,
           register ssize_t
             j;
 
-          if ((GetPixelWriteMask(image,q) <= (QuantumRange/2)) ||
-              IsPixelGray(image,q) != MagickFalse)
+          if (IsPixelGray(image,q) != MagickFalse)
             {
               q+=GetPixelChannels(image);
               continue;
@@ -3555,11 +3507,6 @@ MagickExport MagickBooleanType NegateImage(Image *image,
       register ssize_t
         j;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (j=0; j < (ssize_t) GetPixelChannels(image); j++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,j);
@@ -3859,11 +3806,6 @@ MagickExport MagickBooleanType SigmoidalContrastImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index 99ef1f746d65fe79963d7dd878c087c542df1c66..60c976ac5dc950b04010871fd33cbf8650975c73 100644 (file)
@@ -366,8 +366,7 @@ MagickExport Image *AddNoiseImage(const Image *image,const NoiseType noise_type,
         if ((traits == UndefinedPixelTrait) ||
             (noise_traits == UndefinedPixelTrait))
           continue;
-        if (((noise_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((noise_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(noise_image,channel,p[i],q);
             continue;
@@ -771,8 +770,7 @@ MagickExport Image *ColorizeImage(const Image *image,const char *blend,
           (PixelChannel) i);
         if (traits == UndefinedPixelTrait)
           continue;
-        if (((traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(colorize_image,q) <= (QuantumRange/2)))
+        if ((traits & CopyPixelTrait) != 0)
           continue;
         SetPixelChannel(colorize_image,(PixelChannel) i,ClampToQuantum(
           Colorize(q[i],GetPixelInfoChannel(&blend_percentage,(PixelChannel) i),
@@ -3185,8 +3183,7 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
         if ((traits == UndefinedPixelTrait) ||
             (fx_traits == UndefinedPixelTrait))
           continue;
-        if (((fx_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((fx_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(fx_image,channel,p[i],q);
             continue;
@@ -3380,13 +3377,6 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
       /*
         Determine if the pixel is within an ellipse.
       */
-      if (GetPixelWriteMask(canvas,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(implode_image,q);
-          p+=GetPixelChannels(canvas);
-          q+=GetPixelChannels(implode_image);
-          continue;
-        }
       delta.x=scale.x*(double) (x-center.x);
       distance=delta.x*delta.x+delta.y*delta.y;
       if (distance >= (radius*radius))
@@ -3626,8 +3616,7 @@ MagickExport Image *MorphImages(const Image *image,const size_t number_frames,
             if ((traits == UndefinedPixelTrait) ||
                 (morph_traits == UndefinedPixelTrait))
               continue;
-            if (((morph_traits & CopyPixelTrait) != 0) ||
-                (GetPixelWriteMask(morph_images,p) <= (QuantumRange/2)))
+            if ((morph_traits & CopyPixelTrait) != 0)
               {
                 SetPixelChannel(morph_image,channel,p[i],q);
                 continue;
@@ -4569,11 +4558,6 @@ MagickExport Image *SketchImage(const Image *image,const double radius,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(random_image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(random_image);
-          continue;
-        }
       value=GetPseudoRandomValue(random_info[id]);
       for (i=0; i < (ssize_t) GetPixelChannels(random_image); i++)
       {
@@ -4732,11 +4716,6 @@ MagickExport MagickBooleanType SolarizeImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -5229,13 +5208,6 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
       /*
         Determine if the pixel is within an ellipse.
       */
-      if (GetPixelWriteMask(canvas,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(swirl_image,q);
-          p+=GetPixelChannels(canvas);
-          q+=GetPixelChannels(swirl_image);
-          continue;
-        }
       delta.x=scale.x*(double) (x-center.x);
       distance=delta.x*delta.x+delta.y*delta.y;
       if (distance >= (radius*radius))
@@ -5457,13 +5429,6 @@ MagickExport Image *TintImage(const Image *image,const char *blend,
         weight;
 
       GetPixelInfo(image,&pixel);
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelViaPixelInfo(tint_image,&pixel,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(tint_image);
-          continue;
-        }
       weight=QuantumScale*GetPixelRed(image,p)-0.5;
       pixel.red=(MagickRealType) GetPixelRed(image,p)+color_vector.red*
         (1.0-(4.0*(weight*weight)));
index 23fae2fde5d68e109f33736ba1c6cab80a25c15e..27461c490dc35b3878476dc5ef4ff741d62c5597 100644 (file)
@@ -583,13 +583,6 @@ MagickExport Image *AppendImages(const Image *images,
       GetPixelInfo(next,&pixel);
       for (x=0; x < (ssize_t) next->columns; x++)
       {
-        if (GetPixelWriteMask(next,p) <= (QuantumRange/2))
-          {
-            SetPixelBackgoundColor(append_image,q);
-            p+=GetPixelChannels(next);
-            q+=GetPixelChannels(append_image);
-            continue;
-          }
         GetPixelInfoPixel(next,p,&pixel);
         SetPixelViaPixelInfo(append_image,&pixel,q);
         p+=GetPixelChannels(next);
@@ -1494,6 +1487,11 @@ MagickExport Image *GetImageMask(const Image *image,const PixelMask type,
     {
       switch (type)
       {
+        case ReadPixelMask:
+        {
+          SetPixelGray(mask_image,GetPixelReadMask(image,p),q);
+          break;
+        }
         case WritePixelMask:
         {
           SetPixelGray(mask_image,GetPixelWriteMask(image,p),q);
@@ -1501,7 +1499,7 @@ MagickExport Image *GetImageMask(const Image *image,const PixelMask type,
         }
         default:
         {
-          SetPixelGray(mask_image,GetPixelReadMask(image,p),q);
+          SetPixelGray(mask_image,GetPixelCompositeMask(image,p),q);
           break;
         }
       }
@@ -1828,11 +1826,6 @@ MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         double
@@ -2360,9 +2353,7 @@ MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha,
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) > (QuantumRange/2))
-        SetPixelAlpha(image,alpha,q);
-      else if (set_opaque != MagickFalse)
+      if (set_opaque != MagickFalse)
         SetPixelAlpha(image,OpaqueAlpha,q);
       q+=GetPixelChannels(image);
     }
@@ -3189,15 +3180,17 @@ MagickExport MagickBooleanType SetImageMask(Image *image,const PixelMask type,
     {
       switch (type)
       {
+        case ReadPixelMask: image->read_mask=MagickFalse; break;
         case WritePixelMask: image->write_mask=MagickFalse; break;
-        default: image->read_mask=MagickFalse; break;
+        default: image->composite_mask=MagickFalse; break;
       }
       return(SyncImagePixelCache(image,exception));
     }
   switch (type)
   {
+    case ReadPixelMask: image->read_mask=MagickTrue; break;
     case WritePixelMask: image->write_mask=MagickTrue; break;
-    default: image->read_mask=MagickTrue; break;
+    default: image->composite_mask=MagickTrue; break;
   }
   if (SyncImagePixelCache(image,exception) == MagickFalse)
     return(MagickFalse);
@@ -3238,6 +3231,11 @@ MagickExport MagickBooleanType SetImageMask(Image *image,const PixelMask type,
         intensity=GetPixelIntensity(mask,p);
       switch (type)
       {
+        case ReadPixelMask:
+        {
+          SetPixelReadMask(image,ClampToQuantum(intensity),q);
+          break;
+        }
         case WritePixelMask:
         {
           SetPixelWriteMask(image,ClampToQuantum(intensity),q);
@@ -3245,7 +3243,7 @@ MagickExport MagickBooleanType SetImageMask(Image *image,const PixelMask type,
         }
         default:
         {
-          SetPixelReadMask(image,ClampToQuantum(intensity),q);
+          SetPixelCompositeMask(image,ClampToQuantum(intensity),q);
           break;
         }
       }
@@ -3313,15 +3311,17 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image,
     {
       switch (type)
       {
+        case ReadPixelMask: image->read_mask=MagickFalse; break;
         case WritePixelMask: image->write_mask=MagickFalse; break;
-        default: image->read_mask=MagickFalse; break;
+        default: image->composite_mask=MagickFalse; break;
       }
       return(SyncImagePixelCache(image,exception));
     }
   switch (type)
   {
+    case ReadPixelMask: image->read_mask=MagickTrue; break;
     case WritePixelMask: image->write_mask=MagickTrue; break;
-    default: image->read_mask=MagickTrue; break;
+    default: image->composite_mask=MagickTrue; break;
   }
   if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
     return(MagickFalse);
@@ -3358,6 +3358,11 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image,
         pixel=QuantumRange;
       switch (type)
       {
+        case ReadPixelMask:
+        {
+          SetPixelReadMask(image,pixel,q);
+          break;
+        }
         case WritePixelMask:
         {
           SetPixelWriteMask(image,pixel,q);
@@ -3365,7 +3370,7 @@ MagickExport MagickBooleanType SetImageRegionMask(Image *image,
         }
         default:
         {
-          SetPixelReadMask(image,pixel,q);
+          SetPixelCompositeMask(image,pixel,q);
           break;
         }
       }
index f5415ebf79c02983d877e18ef22b7a03238ea7d9..1ef596baa7b54b8e6fa35ca5221abf791dc9992a 100644 (file)
@@ -355,6 +355,9 @@ struct _Image
 
   PixelInfo
     matte_color;        /* current mattecolor attribute */
+
+  MagickBooleanType
+    composite_mask;
 };
 
 /*
index 37bc4d0739a8b8abaa11879ee13c6bf354d2cace..dfe941b8fb513a6f763254f65635f1f23cd19cbc 100644 (file)
@@ -2720,8 +2720,7 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image,
             if ((traits == UndefinedPixelTrait) ||
                 (morphology_traits == UndefinedPixelTrait))
               continue;
-            if (((traits & CopyPixelTrait) != 0) ||
-                (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+            if ((traits & CopyPixelTrait) != 0)
               {
                 SetPixelChannel(morphology_image,channel,p[center+i],q);
                 continue;
@@ -2871,8 +2870,7 @@ static ssize_t MorphologyPrimitive(const Image *image,Image *morphology_image,
         if ((traits == UndefinedPixelTrait) ||
             (morphology_traits == UndefinedPixelTrait))
           continue;
-        if (((traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(morphology_image,channel,p[center+i],q);
             continue;
@@ -3292,9 +3290,6 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
     register ssize_t
       x;
 
-    ssize_t
-      center;
-
     /*
       Read virtual pixels, and authentic pixels, from the same image!  We read
       using virtual to get virtual pixel handling, but write back into the same
@@ -3314,8 +3309,6 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
         status=MagickFalse;
         continue;
       }
-    center=(ssize_t) (GetPixelChannels(image)*width*offset.y+
-      GetPixelChannels(image)*offset.x);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
       register ssize_t
@@ -3348,8 +3341,7 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
         traits=GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if (((traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((traits & CopyPixelTrait) != 0)
           continue;
         pixels=p;
         pixel=(double) QuantumRange;
@@ -3457,9 +3449,6 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
     register ssize_t
       x;
 
-    ssize_t
-      center;
-
     /*
        Read virtual pixels, and authentic pixels, from the same image.  We
        read using virtual to get virtual pixel handling, but write back
@@ -3480,7 +3469,6 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
       }
     p+=(image->columns-1)*GetPixelChannels(image);
     q+=(image->columns-1)*GetPixelChannels(image);
-    center=(ssize_t) (offset.x*GetPixelChannels(image));
     for (x=(ssize_t) image->columns-1; x >= 0; x--)
     {
       register ssize_t
@@ -3513,8 +3501,7 @@ static ssize_t MorphologyPrimitiveDirect(Image *image,
         traits=GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if (((traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p+center) <= (QuantumRange/2)))
+        if ((traits & CopyPixelTrait) != 0)
           continue;
         pixels=p;
         pixel=(double) QuantumRange;
index 8a3503b13629754d156dcddfe253483655f3788a..054f9492de66331dea13258f07c89180190c8dd8 100644 (file)
@@ -1769,6 +1769,7 @@ static const OptionInfo
     { "Blue", BluePixelChannel, UndefinedOptionFlag, MagickFalse },
     { "Cb", CbPixelChannel, UndefinedOptionFlag, MagickFalse },
     { "Composite", CompositePixelChannel, UndefinedOptionFlag, MagickFalse },
+    { "CompositeMask", CompositeMaskPixelChannel, UndefinedOptionFlag, MagickFalse },
     { "C", CyanPixelChannel, UndefinedOptionFlag, MagickFalse },
     { "Cr", CrPixelChannel, UndefinedOptionFlag, MagickFalse },
     { "Cyan", CyanPixelChannel, UndefinedOptionFlag, MagickFalse },
index 07ce0f54b9d74c50942457773db9fd0e53769032..cf709610221daf98bd894cbbca860df3d0a9094c 100644 (file)
@@ -828,8 +828,7 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
         if ((traits == UndefinedPixelTrait) ||
             (paint_traits == UndefinedPixelTrait))
           continue;
-        if (((paint_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(linear_image,p) <= (QuantumRange/2)))
+        if ((paint_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(paint_image,channel,p[center+i],q);
             continue;
@@ -970,11 +969,6 @@ MagickExport MagickBooleanType OpaquePaintImage(Image *image,
     pixel=zero;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       GetPixelInfoPixel(image,q,&pixel);
       if (IsFuzzyEquivalencePixelInfo(&pixel,&conform_target) != invert)
         {
@@ -1121,11 +1115,6 @@ MagickExport MagickBooleanType TransparentPaintImage(Image *image,
     pixel=zero;
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       GetPixelInfoPixel(image,q,&pixel);
       if (IsFuzzyEquivalencePixelInfo(&pixel,target) != invert)
         SetPixelAlpha(image,opacity,q);
@@ -1256,11 +1245,6 @@ MagickExport MagickBooleanType TransparentPaintImageChroma(Image *image,
     GetPixelInfo(image,&pixel);
     for (x=0; x < (ssize_t) image->columns; x++)
     {
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       GetPixelInfoPixel(image,q,&pixel);
       match=((pixel.red >= low->red) && (pixel.red <= high->red) &&
         (pixel.green >= low->green) && (pixel.green <= high->green) &&
index bd1a1e6338e9720c2fdc30ac51a3d9e0d483db2c..75c501c7de87302810b8cfd3e866d7147f1f9195 100644 (file)
@@ -139,6 +139,14 @@ static inline size_t GetPixelChannels(const Image *magick_restrict image)
   return(image->number_channels);
 }
 
+static inline Quantum GetPixelCompositeMask(const Image *magick_restrict image,
+  const Quantum *magick_restrict pixel)
+{
+  if (image->channel_map[CompositeMaskPixelChannel].traits == UndefinedPixelTrait)
+    return((Quantum) QuantumRange);
+  return(pixel[image->channel_map[CompositeMaskPixelChannel].offset]);
+}
+
 static inline Quantum GetPixelCr(const Image *magick_restrict image,
   const Quantum *magick_restrict pixel)
 {
@@ -720,6 +728,13 @@ static inline void SetPixelChannelTraits(Image *image,
   image->channel_map[channel].traits=traits;
 }
 
+static inline void SetPixelCompositeMask(const Image *magick_restrict image,
+  const Quantum mask,Quantum *magick_restrict pixel)
+{
+  if (image->channel_map[CompositeMaskPixelChannel].traits != UndefinedPixelTrait)
+    pixel[image->channel_map[CompositeMaskPixelChannel].offset]=mask;
+}
+
 static inline void SetPixelCr(const Image *magick_restrict image,
   const Quantum cr,Quantum *magick_restrict pixel)
 {
index 8f1d596cc2d645e5e4bbef05d270beaa90d44abe..dd55ce52fac1904bccb8efb690988cc524955f7c 100644 (file)
@@ -4372,6 +4372,9 @@ MagickExport void InitializePixelChannelMap(Image *image)
     SetPixelChannelAttributes(image,ReadMaskPixelChannel,CopyPixelTrait,n++);
   if (image->write_mask != MagickFalse)
     SetPixelChannelAttributes(image,WriteMaskPixelChannel,CopyPixelTrait,n++);
+  if (image->composite_mask != MagickFalse)
+    SetPixelChannelAttributes(image,CompositeMaskPixelChannel,CopyPixelTrait,
+      n++);
   image->number_channels=(size_t) n;
   (void) SetPixelChannelMask(image,image->channel_mask);
 }
index e92d562435487cf5e25dfe06cc6c13b8d467b9c9..f19b80e018fbd66b971c946dac62bb5e64d89bbb 100644 (file)
@@ -46,7 +46,8 @@ typedef enum
   IndexChannel = 0x0020,             /* Color Index Table? */
   ReadMaskChannel = 0x0040,          /* Pixel is Not Readable? */
   WriteMaskChannel = 0x0080,         /* Pixel is Write Protected? */
-  MetaChannel = 0x0100,              /* ???? */
+  MetaChannel = 0x0100,              /* not used */
+  CompositeMaskChannel = 0x0200,     /* SVG mask */
   CompositeChannels = 0x001F,
   AllChannels = 0x7ffffff,
   /*
@@ -86,6 +87,7 @@ typedef enum
   ReadMaskPixelChannel = 6,
   WriteMaskPixelChannel = 7,
   MetaPixelChannel = 8,
+  CompositeMaskPixelChannel = 9,
   IntensityPixelChannel = MaxPixelChannels,  /* ???? */
   CompositePixelChannel = MaxPixelChannels,  /* ???? */
   SyncPixelChannel = MaxPixelChannels+1      /* not a real channel */
@@ -126,7 +128,8 @@ typedef enum
 {
   UndefinedPixelMask = 0x000000,
   ReadPixelMask = 0x000001,
-  WritePixelMask = 0x000002
+  WritePixelMask = 0x000002,
+  CompositePixelMask = 0x000004
 } PixelMask;
 
 typedef enum
index 8c42f4dc86063c645e1d257591ee9813ba63067e..43350856c06591f324a4ece77a792a599843579f 100644 (file)
@@ -3921,11 +3921,6 @@ MagickExport size_t ExportQuantumPixels(const Image *image,
         register ssize_t
           i;
 
-        if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-          {
-            q+=GetPixelChannels(image);
-            continue;
-          }
         Sa=QuantumScale*GetPixelAlpha(image,q);
         for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
         {
index f08dd33bd75e42bb3692e2c95c196218ce87d0d6..0a0b1f7f8f8917913152b9f302ce98d2c403e622 100644 (file)
@@ -4280,11 +4280,6 @@ MagickExport size_t ImportQuantumPixels(const Image *image,
         register ssize_t
           i;
 
-        if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-          {
-            q+=GetPixelChannels(image);
-            continue;
-          }
         Sa=QuantumScale*GetPixelAlpha(image,q);
         gamma=PerceptibleReciprocal(Sa);
         for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
index 1d04be6a9726c7ed4a167ffc67f2b71d81186c34..9dbed9202e54ec89f6adbb8b2c401ec5a37621a7 100644 (file)
@@ -1782,11 +1782,6 @@ MagickExport Image *InterpolativeResizeImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(resize_image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(resize_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel
index f8abb69565ab43bbce0993232cbe3c285fbf9681..b41e62662569f65d3680a81d7923a309f2078b6b 100644 (file)
@@ -830,12 +830,6 @@ MagickExport Image *IntegralRotateImage(const Image *image,size_t rotations,
               register ssize_t
                 i;
 
-              if (GetPixelWriteMask(image,tile_pixels) <= (QuantumRange/2))
-                {
-                  tile_pixels-=width*GetPixelChannels(image);
-                  q+=GetPixelChannels(rotate_image);
-                  continue;
-                }
               for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
               {
                 PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -920,11 +914,6 @@ MagickExport Image *IntegralRotateImage(const Image *image,size_t rotations,
             i;
 
           q-=GetPixelChannels(rotate_image);
-          if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-            {
-              p+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1043,12 +1032,6 @@ MagickExport Image *IntegralRotateImage(const Image *image,size_t rotations,
               register ssize_t
                 i;
 
-              if (GetPixelWriteMask(image,tile_pixels) <= (QuantumRange/2))
-                {
-                  tile_pixels+=width*GetPixelChannels(image);
-                  q+=GetPixelChannels(rotate_image);
-                  continue;
-                }
               for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
               {
                 PixelChannel channel = GetPixelChannelChannel(image,i);
index 30d9c5beef5c3f3efb047e4039236a3a7b187a62..f4fe997335ad6d1d9b1b536a5d947770b1c16897 100644 (file)
@@ -670,11 +670,6 @@ MagickExport Image *EvaluateImages(const Image *images,
             register ssize_t
               i;
 
-            if (GetPixelWriteMask(next,p) <= (QuantumRange/2))
-              {
-                p+=GetPixelChannels(next);
-                continue;
-              }
             for (i=0; i < (ssize_t) GetPixelChannels(next); i++)
             {
               PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -735,11 +730,6 @@ MagickExport Image *EvaluateImages(const Image *images,
           register ssize_t
             i;
 
-          if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-            {
-              q+=GetPixelChannels(image);
-              continue;
-            }
           for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
           {
             PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -850,8 +840,7 @@ MagickExport MagickBooleanType EvaluateImage(Image *image,
         PixelTrait traits = GetPixelChannelTraits(image,channel);
         if (traits == UndefinedPixelTrait)
           continue;
-        if (((traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,q) <= (QuantumRange/2)))
+        if ((traits & CopyPixelTrait) != 0)
           continue;
         if ((traits & UpdatePixelTrait) == 0)
           continue;
@@ -1073,11 +1062,6 @@ MagickExport MagickBooleanType FunctionImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1428,11 +1412,6 @@ MagickExport ChannelMoments *GetImageMoments(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1486,11 +1465,6 @@ MagickExport ChannelMoments *GetImageMoments(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1857,11 +1831,6 @@ MagickExport MagickBooleanType GetImageRange(const Image *image,double *minima,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -2015,11 +1984,6 @@ MagickExport ChannelStatistics *GetImageStatistics(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -2312,11 +2276,6 @@ MagickExport Image *PolynomialImage(const Image *images,
         register ssize_t
           i;
 
-        if (GetPixelWriteMask(next,p) <= (QuantumRange/2))
-          {
-            p+=GetPixelChannels(next);
-            continue;
-          }
         for (i=0; i < (ssize_t) GetPixelChannels(next); i++)
         {
           MagickRealType
@@ -2346,11 +2305,6 @@ MagickExport Image *PolynomialImage(const Image *images,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index 89f3c66f5a4ee29eb653fcb92fd08f115cb0403b..3e667770f2fac6c02cb7960e6ff474d55b017e8c 100644 (file)
@@ -275,8 +275,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
       if ((traits == UndefinedPixelTrait) ||
           (threshold_traits == UndefinedPixelTrait))
         continue;
-      if (((threshold_traits & CopyPixelTrait) != 0) ||
-          (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+      if ((threshold_traits & CopyPixelTrait) != 0)
         {
           SetPixelChannel(threshold_image,channel,p[center+i],q);
           continue;
@@ -310,8 +309,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image *image,
         if ((traits == UndefinedPixelTrait) ||
             (threshold_traits == UndefinedPixelTrait))
           continue;
-        if (((threshold_traits & CopyPixelTrait) != 0) ||
-            (GetPixelWriteMask(image,p) <= (QuantumRange/2)))
+        if ((threshold_traits & CopyPixelTrait) != 0)
           {
             SetPixelChannel(threshold_image,channel,p[center+i],q);
             continue;
@@ -859,11 +857,6 @@ MagickExport MagickBooleanType BilevelImage(Image *image,const double threshold,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       pixel=GetPixelIntensity(image,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
@@ -1024,11 +1017,6 @@ MagickExport MagickBooleanType BlackThresholdImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       pixel=GetPixelIntensity(image,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
@@ -1160,11 +1148,6 @@ MagickExport MagickBooleanType ClampImage(Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1799,11 +1782,6 @@ MagickExport MagickBooleanType OrderedDitherImage(Image *image,
         n;
 
       n=0;
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         ssize_t
@@ -1966,11 +1944,6 @@ MagickExport MagickBooleanType PerceptibleImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -2103,11 +2076,6 @@ MagickExport MagickBooleanType RandomThresholdImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         double
@@ -2277,11 +2245,6 @@ MagickExport MagickBooleanType WhiteThresholdImage(Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          q+=GetPixelChannels(image);
-          continue;
-        }
       pixel=GetPixelIntensity(image,q);
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
index d6f58c1812b5aaf884d9a2ab3702e63b2b130704..356c84e3c623f885d4c01e0d715750a0565a2268 100644 (file)
@@ -698,13 +698,6 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(crop_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(crop_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1051,13 +1044,6 @@ MagickExport Image *ExcerptImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(excerpt_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(excerpt_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1249,13 +1235,6 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(flip_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(flip_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1392,11 +1371,6 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
         i;
 
       q-=GetPixelChannels(flop_image);
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1518,13 +1492,6 @@ static MagickBooleanType CopyImageRegion(Image *destination,const Image *source,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(source,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(destination,q);
-          p+=GetPixelChannels(source);
-          q+=GetPixelChannels(destination);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(source); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(source,i);
@@ -1846,13 +1813,6 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(splice_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(splice_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1877,13 +1837,6 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(splice_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(splice_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1951,13 +1904,6 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(splice_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(splice_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -1982,13 +1928,6 @@ MagickExport Image *SpliceImage(const Image *image,
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(splice_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(splice_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -2225,13 +2164,6 @@ MagickExport Image *TransposeImage(const Image *image,ExceptionInfo *exception)
       register ssize_t
         i;
 
-      if (GetPixelWriteMask(image,q) <= (QuantumRange/2))
-        {
-          SetPixelBackgoundColor(transpose_image,q);
-          p+=GetPixelChannels(image);
-          q+=GetPixelChannels(transpose_image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
@@ -2374,11 +2306,6 @@ MagickExport Image *TransverseImage(const Image *image,ExceptionInfo *exception)
         i;
 
       q-=GetPixelChannels(transverse_image);
-      if (GetPixelWriteMask(image,p) <= (QuantumRange/2))
-        {
-          p+=GetPixelChannels(image);
-          continue;
-        }
       for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
       {
         PixelChannel channel = GetPixelChannelChannel(image,i);
index d65141ec30b1043ae8975dfaf337294c43813839..e46edb67579db3be2b5c184f3e343e1fbbbc8940 100644 (file)
@@ -1093,20 +1093,8 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
           }
         if (LocaleCompare("clip-mask",option+1) == 0)
           {
-            CacheView
-              *mask_view;
-
             Image
-              *mask_image;
-
-            register Quantum
-              *magick_restrict q;
-
-            register ssize_t
-              x;
-
-            ssize_t
-              y;
+              *clip_mask;
 
             (void) SyncImageSettings(mogrify_info,*image,exception);
             if (*option == '+')
@@ -1114,42 +1102,18 @@ WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
                 /*
                   Remove a mask.
                 */
-                (void) SetImageMask(*image,ReadPixelMask,(Image *) NULL,
+                (void) SetImageMask(*image,WritePixelMask,(Image *) NULL,
                   exception);
                 break;
               }
             /*
               Set the image mask.
-              FUTURE: This Should Be a SetImageAlphaChannel() call, Or two.
             */
-            mask_image=GetImageCache(mogrify_info,argv[i+1],exception);
-            if (mask_image == (Image *) NULL)
+            clip_mask=GetImageCache(mogrify_info,argv[i+1],exception);
+            if (clip_mask == (Image *) NULL)
               break;
-            if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse)
-              return(MagickFalse);
-            mask_view=AcquireAuthenticCacheView(mask_image,exception);
-            for (y=0; y < (ssize_t) mask_image->rows; y++)
-            {
-              q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
-                exception);
-              if (q == (Quantum *) NULL)
-                break;
-              for (x=0; x < (ssize_t) mask_image->columns; x++)
-              {
-                if (mask_image->alpha_trait == UndefinedPixelTrait)
-                  SetPixelAlpha(mask_image,(Quantum)
-                    GetPixelIntensity(mask_image,q),q);
-                SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q);
-                SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q);
-                SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q);
-                q+=GetPixelChannels(mask_image);
-              }
-              if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse)
-                break;
-            }
-            mask_view=DestroyCacheView(mask_view);
-            mask_image->alpha_trait=BlendPixelTrait;
-            (void) SetImageMask(*image,ReadPixelMask,mask_image,exception);
+            (void) SetImageMask(*image,WritePixelMask,clip_mask,exception);
+            clip_mask=DestroyImage(clip_mask);
             break;
           }
         if (LocaleCompare("clip-path",option+1) == 0)
index aaf2a79edcdc2c4d40e5b827d6048582cf5e6e4f..1a2a5dd7cc0f8c3fe13b0a9524ee3630912a1d5e 100644 (file)
@@ -1980,58 +1980,19 @@ static MagickBooleanType CLISimpleOperatorImage(MagickCLI *cli_wand,
         }
       if (LocaleCompare("clip-mask",option+1) == 0)
         {
-          /* Note: arguments do not have percent escapes expanded */
-          CacheView
-            *mask_view;
-
           Image
-            *mask_image;
-
-          register Quantum
-            *magick_restrict q;
-
-          register ssize_t
-            x;
-
-          ssize_t
-            y;
+            *clip_mask;
 
           if (IfPlusOp) {
             /* use "+clip-mask" Remove the write mask for -clip-path */
-            (void) SetImageMask(_image,ReadPixelMask,(Image *) NULL,_exception);
+            (void) SetImageMask(_image,WritePixelMask,(Image *) NULL,_exception);
             break;
           }
-          mask_image=GetImageCache(_image_info,arg1,_exception);
-          if (mask_image == (Image *) NULL)
+          clip_mask=GetImageCache(_image_info,arg1,_exception);
+          if (clip_mask == (Image *) NULL)
             break;
-          if (SetImageStorageClass(mask_image,DirectClass,_exception) == MagickFalse)
-            break;
-          /* Create a write mask from cli_wand mask image */
-          /* FUTURE: use Alpha operations instead and create a Grey Image */
-          mask_view=AcquireAuthenticCacheView(mask_image,_exception);
-          for (y=0; y < (ssize_t) mask_image->rows; y++)
-          {
-            q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1,
-              _exception);
-            if (q == (Quantum *) NULL)
-              break;
-            for (x=0; x < (ssize_t) mask_image->columns; x++)
-            {
-              if (mask_image->alpha_trait == UndefinedPixelTrait)
-                SetPixelAlpha(mask_image,(Quantum)
-                  GetPixelIntensity(mask_image,q),q);
-              SetPixelGray(mask_image,GetPixelAlpha(mask_image,q),q);
-              q+=GetPixelChannels(mask_image);
-            }
-            if (SyncCacheViewAuthenticPixels(mask_view,_exception) == MagickFalse)
-              break;
-          }
-          /* clean up and set the write mask */
-          mask_view=DestroyCacheView(mask_view);
-          mask_image->alpha_trait=BlendPixelTrait;
-          (void) SetImageColorspace(_image,GRAYColorspace,_exception);
-          (void) SetImageMask(_image,ReadPixelMask,mask_image,_exception);
-          mask_image=DestroyImage(mask_image);
+          (void) SetImageMask(_image,WritePixelMask,clip_mask,_exception);
+          clip_mask=DestroyImage(clip_mask);
           break;
         }
       if (LocaleCompare("clip-path",option+1) == 0)