From 3d4cb88314c20ba74045779ae16451608ca2653f Mon Sep 17 00:00:00 2001 From: cristy Date: Tue, 7 Feb 2012 19:11:26 +0000 Subject: [PATCH] --- MagickCore/cache.c | 60 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 4cc6537ab..de85fc337 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -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: -- 2.40.0