]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/cache-view.c
(no commit message)
[imagemagick] / MagickCore / cache-view.c
index 43da94a2ed8e42f5f45ee6730f72441ad5a643af..5127bdb89e479e17d582b3cc435ce7687b4eddf3 100644 (file)
@@ -23,7 +23,7 @@
 %                               February 2000                                 %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -54,6 +54,7 @@
 #include "MagickCore/exception.h"
 #include "MagickCore/exception-private.h"
 #include "MagickCore/pixel-accessor.h"
+#include "MagickCore/resource_.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/thread-private.h"
 \f
@@ -86,25 +87,70 @@ struct _CacheView
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   A c q u i r e C a c h e V i e w                                           %
+%   A c q u i r e A u t h e n t i c C a c h e V i e w                         %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  AcquireCacheView() acquires a view into the pixel cache, using the
-%  VirtualPixelMethod that is defined within the given image itself.
+%  AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
 %
-%  The format of the AcquireCacheView method is:
+%  The format of the AcquireAuthenticCacheView method is:
 %
-%      CacheView *AcquireCacheView(const Image *image)
+%      CacheView *AcquireAuthenticCacheView(const Image *image,
+%        ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o image: the image.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
+  ExceptionInfo *exception)
+{
+  CacheView
+    *cache_view;
+
+  MagickBooleanType
+    status;
+
+  cache_view=AcquireVirtualCacheView(image,exception);
+  status=SyncImagePixelCache(cache_view->image,exception);
+  if (status == MagickFalse)
+    ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
+  return(cache_view);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   A c q u i r e V i r t u a l C a c h e V i e w                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
+%  using the VirtualPixelMethod that is defined within the given image itself.
+%
+%  The format of the AcquireVirtualCacheView method is:
+%
+%      CacheView *AcquireVirtualCacheView(const Image *image,
+%        ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o image: the image.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
-MagickExport CacheView *AcquireCacheView(const Image *image)
+MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
+  ExceptionInfo *exception)
 {
   CacheView
     *cache_view;
@@ -113,6 +159,7 @@ MagickExport CacheView *AcquireCacheView(const Image *image)
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  (void) exception;
   cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
   if (cache_view == (CacheView *) NULL)
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
@@ -217,32 +264,48 @@ MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w C o l o r s p a c e                               %
+%   G e t C a c h e V i e w A u t h e n t i c P i x e l s                     %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewColorspace() returns the image colorspace associated with the
-%  specified view.
+%  GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
+%  cache as defined by the geometry parameters.   A pointer to the pixels is
+%  returned if the pixels are transferred, otherwise a NULL is returned.
 %
-%  The format of the GetCacheViewColorspace method is:
+%  The format of the GetCacheViewAuthenticPixels method is:
 %
-%      ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
+%      Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
+%        const ssize_t x,const ssize_t y,const size_t columns,
+%        const size_t rows,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
+%    o x,y,columns,rows:  These values define the perimeter of a region of
+%      pixels.
+%
+%    o exception: return any errors or warnings in this structure.
+%
 */
-MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
+MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
+  const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
+  ExceptionInfo *exception)
 {
+  const int
+    id = GetOpenMPThreadId();
+
+  Quantum
+    *pixels;
+
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
-  if (cache_view->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      cache_view->image->filename);
-  return(GetPixelCacheColorspace(cache_view->image->cache));
+  assert(id < (int) cache_view->number_threads);
+  pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
+    cache_view->nexus_info[id],exception);
+  return(pixels);
 }
 \f
 /*
@@ -250,32 +313,41 @@ MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w E x c e p t i o n                                 %
+%   G e t C a c h e V i e w A u t h e n t i c M e t a c o n t e n t           %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewException() returns the image exception associated with the
-%  specified view.
+%  GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
+%  with the last call to SetCacheViewIndexes() or
+%  GetCacheViewAuthenticMetacontent().  The meta-content are authentic and can
+%  be updated.
 %
-%  The format of the GetCacheViewException method is:
+%  The format of the GetCacheViewAuthenticMetacontent() method is:
 %
-%      ExceptionInfo GetCacheViewException(const CacheView *cache_view)
+%      void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
 */
-MagickExport ExceptionInfo *GetCacheViewException(const CacheView *cache_view)
+MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
 {
+  const int
+    id = GetOpenMPThreadId();
+
+  void
+    *metacontent;
+
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
-  if (cache_view->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      cache_view->image->filename);
-  return(&cache_view->image->exception);
+  assert(cache_view->image->cache != (Cache) NULL);
+  assert(id < (int) cache_view->number_threads);
+  metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
+    cache_view->nexus_info[id]);
+  return(metacontent);
 }
 \f
 /*
@@ -283,43 +355,41 @@ MagickExport ExceptionInfo *GetCacheViewException(const CacheView *cache_view)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-+   G e t C a c h e V i e w E x t e n t                                       %
+%   G e t C a c h e V i e w A u t h e n t i c P i x e l Q u e u e             %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewExtent() returns the extent of the pixels associated with the
+%  GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
 %  last call to QueueCacheViewAuthenticPixels() or
-%  GetCacheViewAuthenticPixels().
+%  GetCacheViewAuthenticPixels().  The pixels are authentic and therefore can be
+%  updated.
 %
-%  The format of the GetCacheViewExtent() method is:
+%  The format of the GetCacheViewAuthenticPixelQueue() method is:
 %
-%      MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
+%      Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
 */
-MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
+MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
 {
   const int
     id = GetOpenMPThreadId();
 
-  MagickSizeType
-    extent;
+  Quantum
+    *pixels;
 
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
-  if (cache_view->debug != MagickFalse)
-    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
-      cache_view->image->filename);
   assert(cache_view->image->cache != (Cache) NULL);
   assert(id < (int) cache_view->number_threads);
-  extent=GetPixelCacheNexusExtent(cache_view->image->cache,
+  pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
     cache_view->nexus_info[id]);
-  return(extent);
+  return(pixels);
 }
 \f
 /*
@@ -327,32 +397,32 @@ MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w S t o r a g e C l a s s                           %
+%   G e t C a c h e V i e w C o l o r s p a c e                               %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewStorageClass() returns the image storage class  associated with
-%  the specified view.
+%  GetCacheViewColorspace() returns the image colorspace associated with the
+%  specified view.
 %
-%  The format of the GetCacheViewStorageClass method is:
+%  The format of the GetCacheViewColorspace method is:
 %
-%      ClassType GetCacheViewStorageClass(const CacheView *cache_view)
+%      ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
 */
-MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
+MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
 {
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
   if (cache_view->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       cache_view->image->filename);
-  return(GetPixelCacheStorageClass(cache_view->image->cache));
+  return(GetPixelCacheColorspace(cache_view->image->cache));
 }
 \f
 /*
@@ -360,46 +430,43 @@ MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w A u t h e n t i c P i x e l s                     %
++   G e t C a c h e V i e w E x t e n t                                       %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
-%  cache as defined by the geometry parameters.   A pointer to the pixels is
-%  returned if the pixels are transferred, otherwise a NULL is returned.
+%  GetCacheViewExtent() returns the extent of the pixels associated with the
+%  last call to QueueCacheViewAuthenticPixels() or
+%  GetCacheViewAuthenticPixels().
 %
-%  The format of the GetCacheViewAuthenticPixels method is:
+%  The format of the GetCacheViewExtent() method is:
 %
-%      Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
-%        const ssize_t x,const ssize_t y,const size_t columns,
-%        const size_t rows,ExceptionInfo *exception)
+%      MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
-%    o x,y,columns,rows:  These values define the perimeter of a region of
-%      pixels.
-%
 */
-MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
-  const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
-  ExceptionInfo *exception)
+MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
 {
   const int
     id = GetOpenMPThreadId();
 
-  Quantum
-    *pixels;
+  MagickSizeType
+    extent;
 
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
+  if (cache_view->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      cache_view->image->filename);
+  assert(cache_view->image->cache != (Cache) NULL);
   assert(id < (int) cache_view->number_threads);
-  pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
-    cache_view->nexus_info[id],exception);
-  return(pixels);
+  extent=GetPixelCacheNexusExtent(cache_view->image->cache,
+    cache_view->nexus_info[id]);
+  return(extent);
 }
 \f
 /*
@@ -407,42 +474,31 @@ MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w A u t h e n t i c M e t a c o n t e n t           %
+%   G e t C a c h e V i e w I m a g e                                         %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
-%  with the last call to SetCacheViewIndexes() or
-%  GetCacheViewAuthenticMetacontent().  The meta-content are authentic and can
-%  be updated.
+%  GetCacheViewImage() returns the image associated with the specified view.
 %
-%  The format of the GetCacheViewAuthenticMetacontent() method is:
+%  The format of the GetCacheViewImage method is:
 %
-%      void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
+%      const Image *GetCacheViewImage(const CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
 */
-MagickExport void *GetCacheViewAuthenticMetacontent(
-  CacheView *cache_view)
+MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
 {
-  const int
-    id = GetOpenMPThreadId();
-
-  void
-    *metacontent;
-
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
-  assert(cache_view->image->cache != (Cache) NULL);
-  assert(id < (int) cache_view->number_threads);
-  metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
-    cache_view->nexus_info[id]);
-  return(metacontent);
+  if (cache_view->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      cache_view->image->filename);
+  return(cache_view->image);
 }
 \f
 /*
@@ -450,41 +506,32 @@ MagickExport void *GetCacheViewAuthenticMetacontent(
 %                                                                             %
 %                                                                             %
 %                                                                             %
-%   G e t C a c h e V i e w A u t h e n t i c P i x e l Q u e u e             %
+%   G e t C a c h e V i e w S t o r a g e C l a s s                           %
 %                                                                             %
 %                                                                             %
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
-%  last call to QueueCacheViewAuthenticPixels() or
-%  GetCacheViewAuthenticPixels().  The pixels are authentic and therefore can be
-%  updated.
+%  GetCacheViewStorageClass() returns the image storage class associated with
+%  the specified view.
 %
-%  The format of the GetCacheViewAuthenticPixelQueue() method is:
+%  The format of the GetCacheViewStorageClass method is:
 %
-%      Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
+%      ClassType GetCacheViewStorageClass(const CacheView *cache_view)
 %
 %  A description of each parameter follows:
 %
 %    o cache_view: the cache view.
 %
 */
-MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
+MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
 {
-  const int
-    id = GetOpenMPThreadId();
-
-  Quantum
-    *pixels;
-
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
-  assert(cache_view->image->cache != (Cache) NULL);
-  assert(id < (int) cache_view->number_threads);
-  pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
-    cache_view->nexus_info[id]);
-  return(pixels);
+  if (cache_view->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      cache_view->image->filename);
+  return(GetPixelCacheStorageClass(cache_view->image->cache));
 }
 \f
 /*
@@ -676,10 +723,15 @@ MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
     cache_view->nexus_info[id],exception);
   if (p == (const Quantum *) NULL)
     {
-      pixel[RedPixelChannel]=cache_view->image->background_color.red;
-      pixel[GreenPixelChannel]=cache_view->image->background_color.green;
-      pixel[BluePixelChannel]=cache_view->image->background_color.blue;
-      pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
+      PixelInfo
+        background_color;
+
+      background_color=cache_view->image->background_color;
+      pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
+      pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
+      pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
+      pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
+      pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
       return(MagickFalse);
     }
   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
@@ -687,7 +739,7 @@ MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
     PixelChannel
       channel;
 
-    channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
+    channel=GetPixelChannelMapChannel(cache_view->image,i);
     pixel[channel]=p[i];
   }
   return(MagickTrue);
@@ -732,7 +784,7 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
   const int
     id = GetOpenMPThreadId();
 
-  const Quantum
+  register const Quantum
     *p;
 
   register ssize_t
@@ -747,10 +799,15 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
     exception);
   if (p == (const Quantum *) NULL)
     {
-      pixel[RedPixelChannel]=cache_view->image->background_color.red;
-      pixel[GreenPixelChannel]=cache_view->image->background_color.green;
-      pixel[BluePixelChannel]=cache_view->image->background_color.blue;
-      pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
+      PixelInfo
+        background_color;
+
+      background_color=cache_view->image->background_color;
+      pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
+      pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
+      pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
+      pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
+      pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
       return(MagickFalse);
     }
   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
@@ -758,7 +815,7 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
     PixelChannel
       channel;
 
-    channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
+    channel=GetPixelChannelMapChannel(cache_view->image,i);
     pixel[channel]=p[i];
   }
   return(MagickTrue);
@@ -769,6 +826,61 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   G e t O n e C a c h e V i e w V i r t u a l P i x e l I n f o             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
+%  (x,y) location.  The image background color is returned if an error occurs.
+%  If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
+%
+%  The format of the GetOneCacheViewVirtualPixelInfo method is:
+%
+%      MagickBooleanType GetOneCacheViewVirtualPixelInfo(
+%        const CacheView *cache_view,const ssize_t x,const ssize_t y,
+%        PixelInfo *pixel,ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o cache_view: the cache view.
+%
+%    o x,y:  These values define the offset of the pixel.
+%
+%    o pixel: return a pixel at the specified (x,y) location.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
+  const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
+  ExceptionInfo *exception)
+{
+  const int
+    id = GetOpenMPThreadId();
+
+  register const Quantum
+    *p;
+
+  assert(cache_view != (CacheView *) NULL);
+  assert(cache_view->signature == MagickSignature);
+  assert(id < (int) cache_view->number_threads);
+  GetPixelInfo(cache_view->image,pixel);
+  p=GetVirtualPixelsFromNexus(cache_view->image,
+    cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
+    exception);
+  if (p == (const Quantum *) NULL)
+    return(MagickFalse);
+  GetPixelInfoPixel(cache_view->image,p,pixel);
+  return(MagickTrue);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   G e t O n e C a c h e V i e w V i r t u a l P i x e l                     %
 %                                                                             %
 %                                                                             %
@@ -821,10 +933,15 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
     cache_view->nexus_info[id],exception);
   if (p == (const Quantum *) NULL)
     {
-      pixel[RedPixelChannel]=cache_view->image->background_color.red;
-      pixel[GreenPixelChannel]=cache_view->image->background_color.green;
-      pixel[BluePixelChannel]=cache_view->image->background_color.blue;
-      pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
+      PixelInfo
+        background_color;
+
+      background_color=cache_view->image->background_color;
+      pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
+      pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
+      pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
+      pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
+      pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
       return(MagickFalse);
     }
   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
@@ -832,7 +949,7 @@ MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
     PixelChannel
       channel;
 
-    channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
+    channel=GetPixelChannelMapChannel(cache_view->image,i);
     pixel[channel]=p[i];
   }
   return(MagickTrue);
@@ -883,8 +1000,8 @@ MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
   assert(id < (int) cache_view->number_threads);
-  pixels=QueueAuthenticNexus(cache_view->image,x,y,columns,rows,
-    cache_view->nexus_info[id],exception);
+  pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
+    MagickFalse,cache_view->nexus_info[id],exception);
   return(pixels);
 }
 \f
@@ -905,7 +1022,7 @@ MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
 %  The format of the SetCacheViewStorageClass method is:
 %
 %      MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
-%        const ClassType storage_class)
+%        const ClassType storage_class,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -913,21 +1030,18 @@ MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
 %
 %    o storage_class: the image storage class: PseudoClass or DirectClass.
 %
+%    o exception: return any errors or warnings in this structure.
+%
 */
 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
-  const ClassType storage_class)
+  const ClassType storage_class,ExceptionInfo *exception)
 {
-  MagickBooleanType
-    status;
-
   assert(cache_view != (CacheView *) NULL);
   assert(cache_view->signature == MagickSignature);
   if (cache_view->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       cache_view->image->filename);
-  status=SetImageStorageClass(cache_view->image,storage_class,
-    &cache_view->image->exception);
-  return(status);
+  return(SetImageStorageClass(cache_view->image,storage_class,exception));
 }
 \f
 /*