From 32867feba16397cfc86f9af7aa92d58b034c6aa1 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 4 Dec 2016 09:02:31 -0500 Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/312 --- MagickCore/cache-private.h | 1 + MagickCore/cache.c | 37 ++++++++++++++++++++++++++++++++++++- MagickCore/stream.c | 5 ++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/MagickCore/cache-private.h b/MagickCore/cache-private.h index 9cf9c33c4..b48f79601 100644 --- a/MagickCore/cache-private.h +++ b/MagickCore/cache-private.h @@ -281,6 +281,7 @@ extern MagickPrivate void GetPixelCacheTileSize(const Image *,size_t *,size_t *), GetPixelCacheMethods(CacheMethods *), ResetPixelCacheEpoch(void), + ResetPixelCacheChannels(Image *), SetPixelCacheMethods(Cache,CacheMethods *); #if defined(MAGICKCORE_OPENCL_SUPPORT) diff --git a/MagickCore/cache.c b/MagickCore/cache.c index 72f9134f6..304eac4d0 100644 --- a/MagickCore/cache.c +++ b/MagickCore/cache.c @@ -4484,7 +4484,42 @@ MagickPrivate Cache ReferencePixelCache(Cache cache) % % % % % % -+ R e s e t P i x e l C a c h e E p o c h e % ++ R e s e t P i x e l C a c h e C h a n n e l s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% ResetPixelCacheChannels() resets the pixel cache channels. +% +% The format of the ResetPixelCacheChannels method is: +% +% void ResetPixelCacheChannels(Image *) +% +% A description of each parameter follows: +% +% o image: the image. +% +*/ +MagickPrivate void ResetPixelCacheChannels(Image *image) +{ + CacheInfo + *magick_restrict cache_info; + + assert(image != (const Image *) NULL); + assert(image->signature == MagickCoreSignature); + assert(image->cache != (Cache) NULL); + cache_info=(CacheInfo *) image->cache; + assert(cache_info->signature == MagickCoreSignature); + cache_info->number_channels=GetPixelChannels(image); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % ++ R e s e t P i x e l C a c h e E p o c h % % % % % % % diff --git a/MagickCore/stream.c b/MagickCore/stream.c index 009d10a26..f62e356e5 100644 --- a/MagickCore/stream.c +++ b/MagickCore/stream.c @@ -1012,7 +1012,10 @@ MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream, read_info->stream=stream; image=ReadImage(read_info,exception); if (image != (Image *) NULL) - (void) SyncImagePixelCache(image,exception); + { + InitializePixelChannelMap(image); + ResetPixelCacheChannels(image); + } read_info=DestroyImageInfo(read_info); return(image); } -- 2.40.0