2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % CCCC AAA CCCC H H EEEEE %
8 % C AAAAA C HHHHH EEE %
10 % CCCC A A CCCC H H EEEEE %
12 % V V IIIII EEEEE W W %
19 % MagickCore Cache View Methods %
26 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 #include "MagickCore/studio.h"
50 #include "MagickCore/cache.h"
51 #include "MagickCore/cache-private.h"
52 #include "MagickCore/cache-view.h"
53 #include "MagickCore/memory_.h"
54 #include "MagickCore/exception.h"
55 #include "MagickCore/exception-private.h"
56 #include "MagickCore/pixel-accessor.h"
57 #include "MagickCore/string_.h"
58 #include "MagickCore/thread-private.h"
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 % 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 %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
97 % The format of the AcquireAuthenticCacheView method is:
99 % CacheView *AcquireAuthenticCacheView(const Image *image,
100 % ExceptionInfo *exception)
102 % A description of each parameter follows:
104 % o image: the image.
106 % o exception: return any errors or warnings in this structure.
109 MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
110 ExceptionInfo *exception)
118 cache_view=AcquireVirtualCacheView(image,exception);
119 status=SyncImagePixelCache(cache_view->image,exception);
120 if (status == MagickFalse)
121 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 % A c q u i r e V i r t u a l C a c h e V i e w %
134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
137 % using the VirtualPixelMethod that is defined within the given image itself.
139 % The format of the AcquireVirtualCacheView method is:
141 % CacheView *AcquireVirtualCacheView(const Image *image,
142 % ExceptionInfo *exception)
144 % A description of each parameter follows:
146 % o image: the image.
148 % o exception: return any errors or warnings in this structure.
151 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
152 ExceptionInfo *exception)
157 assert(image != (Image *) NULL);
158 assert(image->signature == MagickSignature);
159 if (image->debug != MagickFalse)
160 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
162 cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
163 if (cache_view == (CacheView *) NULL)
164 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
165 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
166 cache_view->image=ReferenceImage((Image *) image);
167 cache_view->number_threads=GetOpenMPMaximumThreads();
168 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
169 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
170 cache_view->debug=IsEventLogging();
171 cache_view->signature=MagickSignature;
172 if (cache_view->nexus_info == (NexusInfo **) NULL)
173 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 % C l o n e C a c h e V i e w %
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188 % CloneCacheView() makes an exact copy of the specified cache view.
190 % The format of the CloneCacheView method is:
192 % CacheView *CloneCacheView(const CacheView *cache_view)
194 % A description of each parameter follows:
196 % o cache_view: the cache view.
199 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
204 assert(cache_view != (CacheView *) NULL);
205 assert(cache_view->signature == MagickSignature);
206 if (cache_view->debug != MagickFalse)
207 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
208 cache_view->image->filename);
209 clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
210 if (clone_view == (CacheView *) NULL)
211 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
212 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
213 clone_view->image=ReferenceImage(cache_view->image);
214 clone_view->number_threads=cache_view->number_threads;
215 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
216 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
217 clone_view->debug=cache_view->debug;
218 clone_view->signature=MagickSignature;
223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
227 % D e s t r o y C a c h e V i e w %
231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233 % DestroyCacheView() destroys the specified view returned by a previous call
234 % to AcquireCacheView().
236 % The format of the DestroyCacheView method is:
238 % CacheView *DestroyCacheView(CacheView *cache_view)
240 % A description of each parameter follows:
242 % o cache_view: the cache view.
245 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
247 assert(cache_view != (CacheView *) NULL);
248 assert(cache_view->signature == MagickSignature);
249 if (cache_view->debug != MagickFalse)
250 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
251 cache_view->image->filename);
252 if (cache_view->nexus_info != (NexusInfo **) NULL)
253 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
254 cache_view->number_threads);
255 cache_view->image=DestroyImage(cache_view->image);
256 cache_view->signature=(~MagickSignature);
257 cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 % G e t C a c h e V i e w C o l o r s p a c e %
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 % GetCacheViewColorspace() returns the image colorspace associated with the
275 % The format of the GetCacheViewColorspace method is:
277 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
279 % A description of each parameter follows:
281 % o cache_view: the cache view.
284 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
286 assert(cache_view != (CacheView *) NULL);
287 assert(cache_view->signature == MagickSignature);
288 if (cache_view->debug != MagickFalse)
289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
290 cache_view->image->filename);
291 return(GetPixelCacheColorspace(cache_view->image->cache));
295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299 + G e t C a c h e V i e w E x t e n t %
303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 % GetCacheViewExtent() returns the extent of the pixels associated with the
306 % last call to QueueCacheViewAuthenticPixels() or
307 % GetCacheViewAuthenticPixels().
309 % The format of the GetCacheViewExtent() method is:
311 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
313 % A description of each parameter follows:
315 % o cache_view: the cache view.
318 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
321 id = GetOpenMPThreadId();
326 assert(cache_view != (CacheView *) NULL);
327 assert(cache_view->signature == MagickSignature);
328 if (cache_view->debug != MagickFalse)
329 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
330 cache_view->image->filename);
331 assert(cache_view->image->cache != (Cache) NULL);
332 assert(id < (int) cache_view->number_threads);
333 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
334 cache_view->nexus_info[id]);
339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343 % G e t C a c h e V i e w S t o r a g e C l a s s %
347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
349 % GetCacheViewStorageClass() returns the image storage class associated with
350 % the specified view.
352 % The format of the GetCacheViewStorageClass method is:
354 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
356 % A description of each parameter follows:
358 % o cache_view: the cache view.
361 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
363 assert(cache_view != (CacheView *) NULL);
364 assert(cache_view->signature == MagickSignature);
365 if (cache_view->debug != MagickFalse)
366 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
367 cache_view->image->filename);
368 return(GetPixelCacheStorageClass(cache_view->image->cache));
372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
376 % 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 %
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
382 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
383 % cache as defined by the geometry parameters. A pointer to the pixels is
384 % returned if the pixels are transferred, otherwise a NULL is returned.
386 % The format of the GetCacheViewAuthenticPixels method is:
388 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
389 % const ssize_t x,const ssize_t y,const size_t columns,
390 % const size_t rows,ExceptionInfo *exception)
392 % A description of each parameter follows:
394 % o cache_view: the cache view.
396 % o x,y,columns,rows: These values define the perimeter of a region of
399 % o exception: return any errors or warnings in this structure.
402 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
403 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
404 ExceptionInfo *exception)
407 id = GetOpenMPThreadId();
412 assert(cache_view != (CacheView *) NULL);
413 assert(cache_view->signature == MagickSignature);
414 assert(id < (int) cache_view->number_threads);
415 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
416 cache_view->nexus_info[id],exception);
421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425 % 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 %
429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
432 % with the last call to SetCacheViewIndexes() or
433 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
436 % The format of the GetCacheViewAuthenticMetacontent() method is:
438 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
440 % A description of each parameter follows:
442 % o cache_view: the cache view.
445 MagickExport void *GetCacheViewAuthenticMetacontent(
446 CacheView *cache_view)
449 id = GetOpenMPThreadId();
454 assert(cache_view != (CacheView *) NULL);
455 assert(cache_view->signature == MagickSignature);
456 assert(cache_view->image->cache != (Cache) NULL);
457 assert(id < (int) cache_view->number_threads);
458 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
459 cache_view->nexus_info[id]);
464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 % 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 %
472 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
475 % last call to QueueCacheViewAuthenticPixels() or
476 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
479 % The format of the GetCacheViewAuthenticPixelQueue() method is:
481 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
483 % A description of each parameter follows:
485 % o cache_view: the cache view.
488 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
491 id = GetOpenMPThreadId();
496 assert(cache_view != (CacheView *) NULL);
497 assert(cache_view->signature == MagickSignature);
498 assert(cache_view->image->cache != (Cache) NULL);
499 assert(id < (int) cache_view->number_threads);
500 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
501 cache_view->nexus_info[id]);
506 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510 % G e t C a c h e V i e w V i r t u a l M e t a c o n t e n t %
514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
517 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
518 % is virtual and therefore cannot be updated.
520 % The format of the GetCacheViewVirtualMetacontent() method is:
522 % const void *GetCacheViewVirtualMetacontent(
523 % const CacheView *cache_view)
525 % A description of each parameter follows:
527 % o cache_view: the cache view.
530 MagickExport const void *GetCacheViewVirtualMetacontent(
531 const CacheView *cache_view)
534 id = GetOpenMPThreadId();
539 assert(cache_view != (const CacheView *) NULL);
540 assert(cache_view->signature == MagickSignature);
541 assert(cache_view->image->cache != (Cache) NULL);
542 assert(id < (int) cache_view->number_threads);
543 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
544 cache_view->nexus_info[id]);
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
553 % G e t C a c h e V i e w V i r t u a l P i x e l Q u e u e %
557 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
559 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
560 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
561 % and therefore cannot be updated.
563 % The format of the GetCacheViewVirtualPixelQueue() method is:
565 % const Quantum *GetCacheViewVirtualPixelQueue(
566 % const CacheView *cache_view)
568 % A description of each parameter follows:
570 % o cache_view: the cache view.
573 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
574 const CacheView *cache_view)
577 id = GetOpenMPThreadId();
582 assert(cache_view != (const CacheView *) NULL);
583 assert(cache_view->signature == MagickSignature);
584 assert(cache_view->image->cache != (Cache) NULL);
585 assert(id < (int) cache_view->number_threads);
586 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
587 cache_view->nexus_info[id]);
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
596 % G e t C a c h e V i e w V i r t u a l P i x e l s %
600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
603 % disk pixel cache as defined by the geometry parameters. A pointer to the
604 % pixels is returned if the pixels are transferred, otherwise a NULL is
607 % The format of the GetCacheViewVirtualPixels method is:
609 % const Quantum *GetCacheViewVirtualPixels(
610 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
611 % const size_t columns,const size_t rows,ExceptionInfo *exception)
613 % A description of each parameter follows:
615 % o cache_view: the cache view.
617 % o x,y,columns,rows: These values define the perimeter of a region of
620 % o exception: return any errors or warnings in this structure.
623 MagickExport const Quantum *GetCacheViewVirtualPixels(
624 const CacheView *cache_view,const ssize_t x,const ssize_t y,
625 const size_t columns,const size_t rows,ExceptionInfo *exception)
628 id = GetOpenMPThreadId();
633 assert(cache_view != (CacheView *) NULL);
634 assert(cache_view->signature == MagickSignature);
635 assert(id < (int) cache_view->number_threads);
636 pixels=GetVirtualPixelsFromNexus(cache_view->image,
637 cache_view->virtual_pixel_method,x,y,columns,rows,
638 cache_view->nexus_info[id],exception);
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
647 % G e t O n e C a c h e V i e w A u t h e n t i c P i x e l %
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
654 % location. The image background color is returned if an error occurs.
656 % The format of the GetOneCacheViewAuthenticPixel method is:
658 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
659 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
660 % Quantum *pixel,ExceptionInfo *exception)
662 % A description of each parameter follows:
664 % o cache_view: the cache view.
666 % o x,y: These values define the offset of the pixel.
668 % o pixel: return a pixel at the specified (x,y) location.
670 % o exception: return any errors or warnings in this structure.
673 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
674 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
675 ExceptionInfo *exception)
678 id = GetOpenMPThreadId();
686 assert(cache_view != (CacheView *) NULL);
687 assert(cache_view->signature == MagickSignature);
688 assert(id < (int) cache_view->number_threads);
689 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
690 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
691 cache_view->nexus_info[id],exception);
692 if (p == (const Quantum *) NULL)
697 background_color=cache_view->image->background_color;
698 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
699 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
700 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
701 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
702 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
705 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
710 channel=GetPixelChannelMapChannel(cache_view->image,i);
717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 % 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 %
725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
727 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
728 % location. The image background color is returned if an error occurs. If
729 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
731 % The format of the GetOneCacheViewVirtualPixel method is:
733 % MagickBooleanType GetOneCacheViewVirtualPixel(
734 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
735 % Quantum *pixel,ExceptionInfo *exception)
737 % A description of each parameter follows:
739 % o cache_view: the cache view.
741 % o x,y: These values define the offset of the pixel.
743 % o pixel: return a pixel at the specified (x,y) location.
745 % o exception: return any errors or warnings in this structure.
748 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
749 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
750 ExceptionInfo *exception)
753 id = GetOpenMPThreadId();
755 register const Quantum
761 assert(cache_view != (CacheView *) NULL);
762 assert(cache_view->signature == MagickSignature);
763 assert(id < (int) cache_view->number_threads);
764 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
765 p=GetVirtualPixelsFromNexus(cache_view->image,
766 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
768 if (p == (const Quantum *) NULL)
773 background_color=cache_view->image->background_color;
774 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
775 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
776 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
777 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
778 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
781 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
786 channel=GetPixelChannelMapChannel(cache_view->image,i);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % 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 %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
804 % (x,y) location. The image background color is returned if an error occurs.
805 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
807 % The format of the GetOneCacheViewVirtualPixelInfo method is:
809 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
810 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
811 % PixelInfo *pixel,ExceptionInfo *exception)
813 % A description of each parameter follows:
815 % o cache_view: the cache view.
817 % o x,y: These values define the offset of the pixel.
819 % o pixel: return a pixel at the specified (x,y) location.
821 % o exception: return any errors or warnings in this structure.
824 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
825 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
826 ExceptionInfo *exception)
829 id = GetOpenMPThreadId();
831 register const Quantum
834 assert(cache_view != (CacheView *) NULL);
835 assert(cache_view->signature == MagickSignature);
836 assert(id < (int) cache_view->number_threads);
837 GetPixelInfo(cache_view->image,pixel);
838 p=GetVirtualPixelsFromNexus(cache_view->image,
839 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
841 if (p == (const Quantum *) NULL)
843 GetPixelInfoPixel(cache_view->image,p,pixel);
848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852 % 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 %
856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
858 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
859 % the specified (x,y) location. The image background color is returned if an
860 % error occurs. If you plan to modify the pixel, use
861 % GetOneCacheViewAuthenticPixel() instead.
863 % The format of the GetOneCacheViewVirtualPixel method is:
865 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
866 % const CacheView *cache_view,
867 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
868 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
870 % A description of each parameter follows:
872 % o cache_view: the cache view.
874 % o virtual_pixel_method: the virtual pixel method.
876 % o x,y: These values define the offset of the pixel.
878 % o pixel: return a pixel at the specified (x,y) location.
880 % o exception: return any errors or warnings in this structure.
883 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
884 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
885 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
888 id = GetOpenMPThreadId();
896 assert(cache_view != (CacheView *) NULL);
897 assert(cache_view->signature == MagickSignature);
898 assert(id < (int) cache_view->number_threads);
899 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
900 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
901 cache_view->nexus_info[id],exception);
902 if (p == (const Quantum *) NULL)
907 background_color=cache_view->image->background_color;
908 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
909 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
910 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
911 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
912 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
915 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
920 channel=GetPixelChannelMapChannel(cache_view->image,i);
927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
931 % Q u e u e C a c h e V i e w A u t h e n t i c P i x e l s %
935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
937 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
938 % disk pixel cache as defined by the geometry parameters. A pointer to the
939 % pixels is returned if the pixels are transferred, otherwise a NULL is
942 % The format of the QueueCacheViewAuthenticPixels method is:
944 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
945 % const ssize_t x,const ssize_t y,const size_t columns,
946 % const size_t rows,ExceptionInfo *exception)
948 % A description of each parameter follows:
950 % o cache_view: the cache view.
952 % o x,y,columns,rows: These values define the perimeter of a region of
955 % o exception: return any errors or warnings in this structure.
958 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
959 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
960 ExceptionInfo *exception)
963 id = GetOpenMPThreadId();
968 assert(cache_view != (CacheView *) NULL);
969 assert(cache_view->signature == MagickSignature);
970 assert(id < (int) cache_view->number_threads);
971 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
972 MagickFalse,cache_view->nexus_info[id],exception);
977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
981 % S e t C a c h e V i e w S t o r a g e C l a s s %
985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
987 % SetCacheViewStorageClass() sets the image storage class associated with
988 % the specified view.
990 % The format of the SetCacheViewStorageClass method is:
992 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
993 % const ClassType storage_class,ExceptionInfo *exception)
995 % A description of each parameter follows:
997 % o cache_view: the cache view.
999 % o storage_class: the image storage class: PseudoClass or DirectClass.
1001 % o exception: return any errors or warnings in this structure.
1004 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1005 const ClassType storage_class,ExceptionInfo *exception)
1007 assert(cache_view != (CacheView *) NULL);
1008 assert(cache_view->signature == MagickSignature);
1009 if (cache_view->debug != MagickFalse)
1010 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1011 cache_view->image->filename);
1012 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020 % S e t C a c h e V i e w V i r t u a l P i x e l M e t h o d %
1024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1026 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1027 % with the specified cache view.
1029 % The format of the SetCacheViewVirtualPixelMethod method is:
1031 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1032 % const VirtualPixelMethod virtual_pixel_method)
1034 % A description of each parameter follows:
1036 % o cache_view: the cache view.
1038 % o virtual_pixel_method: the virtual pixel method.
1041 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1042 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1044 assert(cache_view != (CacheView *) NULL);
1045 assert(cache_view->signature == MagickSignature);
1046 if (cache_view->debug != MagickFalse)
1047 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1048 cache_view->image->filename);
1049 cache_view->virtual_pixel_method=virtual_pixel_method;
1054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1058 % S y n c C a c h e V i e w A u t h e n t i c P i x e l s %
1062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1064 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1065 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1066 % otherwise MagickFalse.
1068 % The format of the SyncCacheViewAuthenticPixels method is:
1070 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1071 % ExceptionInfo *exception)
1073 % A description of each parameter follows:
1075 % o cache_view: the cache view.
1077 % o exception: return any errors or warnings in this structure.
1080 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1081 CacheView *cache_view,ExceptionInfo *exception)
1084 id = GetOpenMPThreadId();
1089 assert(cache_view != (CacheView *) NULL);
1090 assert(cache_view->signature == MagickSignature);
1091 assert(id < (int) cache_view->number_threads);
1092 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1093 cache_view->nexus_info[id],exception);