]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 7 Feb 2012 19:11:26 +0000 (19:11 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 7 Feb 2012 19:11:26 +0000 (19:11 +0000)
MagickCore/cache.c

index 4cc6537abfe351e8faf642328c08f557987414b0..de85fc3379cb073bbaf34da119ee8f621c398383 100644 (file)
@@ -4885,6 +4885,62 @@ static Quantum *SetPixelCacheNexusPixels(const Image *image,
 %    o exception: return any errors or warnings in this structure.
 %
 */
+
+static MagickBooleanType SetCacheAlphaChannel(Image *image,const Quantum alpha,
+  ExceptionInfo *exception)
+{
+  CacheInfo
+    *cache_info;
+
+  MagickBooleanType
+    status;
+
+  ssize_t
+    y;
+
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  if (image->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  assert(image->cache != (Cache) NULL);
+  cache_info=(CacheInfo *) image->cache;
+  assert(cache_info->signature == MagickSignature);
+  image->matte=MagickTrue;
+  status=MagickTrue;
+#if defined(MAGICKCORE_OPENMP_SUPPORT)
+  #pragma omp parallel for schedule(static,4) shared(status)
+#endif
+  for (y=0; y < (ssize_t) image->rows; y++)
+  {
+    const int
+      id = GetOpenMPThreadId();
+
+    register Quantum
+      *restrict q;
+
+    register ssize_t
+      x;
+
+    if (status == MagickFalse)
+      continue;
+    q=GetAuthenticPixelCacheNexus(image,0,y,image->columns,1,
+      cache_info->nexus_info[id],exception);
+    if (q == (Quantum *) NULL)
+      {
+        status=MagickFalse;
+        continue;
+      }
+    for (x=0; x < (ssize_t) image->columns; x++)
+    {
+      SetPixelAlpha(image,alpha,q);
+      q+=GetPixelChannels(image);
+    }
+    status=SyncAuthenticPixelCacheNexus(image,cache_info->nexus_info[id],
+      exception);
+  }
+  return(status);
+}
+
 MagickPrivate VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image,
   const VirtualPixelMethod virtual_pixel_method,ExceptionInfo *exception)
 {
@@ -4909,13 +4965,13 @@ MagickPrivate VirtualPixelMethod SetPixelCacheVirtualMethod(Image *image,
     {
       if ((image->background_color.matte != MagickFalse) &&
           (image->matte == MagickFalse))
-        (void) SetImageAlpha(image,OpaqueAlpha,exception);
+        (void) SetCacheAlphaChannel(image,OpaqueAlpha,exception);
       break;
     }
     case TransparentVirtualPixelMethod:
     {
       if (image->matte == MagickFalse)
-        (void) SetImageAlpha(image,OpaqueAlpha,exception);
+        (void) SetCacheAlphaChannel(image,OpaqueAlpha,exception);
       break;
     }
     default: