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-2011 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 C a c h e V i e w %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % AcquireCacheView() acquires a view into the pixel cache, using the
96 % VirtualPixelMethod that is defined within the given image itself.
98 % The format of the AcquireCacheView method is:
100 % CacheView *AcquireCacheView(const Image *image)
102 % A description of each parameter follows:
104 % o image: the image.
107 MagickExport CacheView *AcquireCacheView(const Image *image)
112 assert(image != (Image *) NULL);
113 assert(image->signature == MagickSignature);
114 if (image->debug != MagickFalse)
115 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
116 cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
117 if (cache_view == (CacheView *) NULL)
118 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
119 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
120 cache_view->image=ReferenceImage((Image *) image);
121 cache_view->number_threads=GetOpenMPMaximumThreads();
122 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
123 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
124 cache_view->debug=IsEventLogging();
125 cache_view->signature=MagickSignature;
126 if (cache_view->nexus_info == (NexusInfo **) NULL)
127 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 % C l o n e C a c h e V i e w %
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % CloneCacheView() makes an exact copy of the specified cache view.
144 % The format of the CloneCacheView method is:
146 % CacheView *CloneCacheView(const CacheView *cache_view)
148 % A description of each parameter follows:
150 % o cache_view: the cache view.
153 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
158 assert(cache_view != (CacheView *) NULL);
159 assert(cache_view->signature == MagickSignature);
160 if (cache_view->debug != MagickFalse)
161 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
162 cache_view->image->filename);
163 clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
164 if (clone_view == (CacheView *) NULL)
165 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
166 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
167 clone_view->image=ReferenceImage(cache_view->image);
168 clone_view->number_threads=cache_view->number_threads;
169 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
170 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
171 clone_view->debug=cache_view->debug;
172 clone_view->signature=MagickSignature;
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % D e s t r o y C a c h e V i e w %
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 % DestroyCacheView() destroys the specified view returned by a previous call
188 % to AcquireCacheView().
190 % The format of the DestroyCacheView method is:
192 % CacheView *DestroyCacheView(CacheView *cache_view)
194 % A description of each parameter follows:
196 % o cache_view: the cache view.
199 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
201 assert(cache_view != (CacheView *) NULL);
202 assert(cache_view->signature == MagickSignature);
203 if (cache_view->debug != MagickFalse)
204 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
205 cache_view->image->filename);
206 if (cache_view->nexus_info != (NexusInfo **) NULL)
207 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
208 cache_view->number_threads);
209 cache_view->image=DestroyImage(cache_view->image);
210 cache_view->signature=(~MagickSignature);
211 cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 % G e t C a c h e V i e w C o l o r s p a c e %
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 % GetCacheViewColorspace() returns the image colorspace associated with the
229 % The format of the GetCacheViewColorspace method is:
231 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
233 % A description of each parameter follows:
235 % o cache_view: the cache view.
238 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
240 assert(cache_view != (CacheView *) NULL);
241 assert(cache_view->signature == MagickSignature);
242 if (cache_view->debug != MagickFalse)
243 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
244 cache_view->image->filename);
245 return(GetPixelCacheColorspace(cache_view->image->cache));
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 + G e t C a c h e V i e w E x t e n t %
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % GetCacheViewExtent() returns the extent of the pixels associated with the
260 % last call to QueueCacheViewAuthenticPixels() or
261 % GetCacheViewAuthenticPixels().
263 % The format of the GetCacheViewExtent() method is:
265 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
267 % A description of each parameter follows:
269 % o cache_view: the cache view.
272 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
275 id = GetOpenMPThreadId();
280 assert(cache_view != (CacheView *) NULL);
281 assert(cache_view->signature == MagickSignature);
282 if (cache_view->debug != MagickFalse)
283 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
284 cache_view->image->filename);
285 assert(cache_view->image->cache != (Cache) NULL);
286 assert(id < (int) cache_view->number_threads);
287 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
288 cache_view->nexus_info[id]);
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 % G e t C a c h e V i e w S t o r a g e C l a s s %
301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
303 % GetCacheViewStorageClass() returns the image storage class associated with
304 % the specified view.
306 % The format of the GetCacheViewStorageClass method is:
308 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
310 % A description of each parameter follows:
312 % o cache_view: the cache view.
315 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
317 assert(cache_view != (CacheView *) NULL);
318 assert(cache_view->signature == MagickSignature);
319 if (cache_view->debug != MagickFalse)
320 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
321 cache_view->image->filename);
322 return(GetPixelCacheStorageClass(cache_view->image->cache));
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 % 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 %
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
337 % cache as defined by the geometry parameters. A pointer to the pixels is
338 % returned if the pixels are transferred, otherwise a NULL is returned.
340 % The format of the GetCacheViewAuthenticPixels method is:
342 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
343 % const ssize_t x,const ssize_t y,const size_t columns,
344 % const size_t rows,ExceptionInfo *exception)
346 % A description of each parameter follows:
348 % o cache_view: the cache view.
350 % o x,y,columns,rows: These values define the perimeter of a region of
354 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
355 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
356 ExceptionInfo *exception)
359 id = GetOpenMPThreadId();
364 assert(cache_view != (CacheView *) NULL);
365 assert(cache_view->signature == MagickSignature);
366 assert(id < (int) cache_view->number_threads);
367 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
368 cache_view->nexus_info[id],exception);
373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377 % 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 %
381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
384 % with the last call to SetCacheViewIndexes() or
385 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
388 % The format of the GetCacheViewAuthenticMetacontent() method is:
390 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
392 % A description of each parameter follows:
394 % o cache_view: the cache view.
397 MagickExport void *GetCacheViewAuthenticMetacontent(
398 CacheView *cache_view)
401 id = GetOpenMPThreadId();
406 assert(cache_view != (CacheView *) NULL);
407 assert(cache_view->signature == MagickSignature);
408 assert(cache_view->image->cache != (Cache) NULL);
409 assert(id < (int) cache_view->number_threads);
410 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
411 cache_view->nexus_info[id]);
416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420 % 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 %
424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
426 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
427 % last call to QueueCacheViewAuthenticPixels() or
428 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
431 % The format of the GetCacheViewAuthenticPixelQueue() method is:
433 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
435 % A description of each parameter follows:
437 % o cache_view: the cache view.
440 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
443 id = GetOpenMPThreadId();
448 assert(cache_view != (CacheView *) NULL);
449 assert(cache_view->signature == MagickSignature);
450 assert(cache_view->image->cache != (Cache) NULL);
451 assert(id < (int) cache_view->number_threads);
452 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
453 cache_view->nexus_info[id]);
458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 % 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 %
466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
469 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
470 % is virtual and therefore cannot be updated.
472 % The format of the GetCacheViewVirtualMetacontent() method is:
474 % const void *GetCacheViewVirtualMetacontent(
475 % const CacheView *cache_view)
477 % A description of each parameter follows:
479 % o cache_view: the cache view.
482 MagickExport const void *GetCacheViewVirtualMetacontent(
483 const CacheView *cache_view)
486 id = GetOpenMPThreadId();
491 assert(cache_view != (const CacheView *) NULL);
492 assert(cache_view->signature == MagickSignature);
493 assert(cache_view->image->cache != (Cache) NULL);
494 assert(id < (int) cache_view->number_threads);
495 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
496 cache_view->nexus_info[id]);
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 % 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 %
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
512 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
513 % and therefore cannot be updated.
515 % The format of the GetCacheViewVirtualPixelQueue() method is:
517 % const Quantum *GetCacheViewVirtualPixelQueue(
518 % const CacheView *cache_view)
520 % A description of each parameter follows:
522 % o cache_view: the cache view.
525 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
526 const CacheView *cache_view)
529 id = GetOpenMPThreadId();
534 assert(cache_view != (const CacheView *) NULL);
535 assert(cache_view->signature == MagickSignature);
536 assert(cache_view->image->cache != (Cache) NULL);
537 assert(id < (int) cache_view->number_threads);
538 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
539 cache_view->nexus_info[id]);
544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548 % 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 %
552 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
555 % disk pixel cache as defined by the geometry parameters. A pointer to the
556 % pixels is returned if the pixels are transferred, otherwise a NULL is
559 % The format of the GetCacheViewVirtualPixels method is:
561 % const Quantum *GetCacheViewVirtualPixels(
562 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
563 % const size_t columns,const size_t rows,ExceptionInfo *exception)
565 % A description of each parameter follows:
567 % o cache_view: the cache view.
569 % o x,y,columns,rows: These values define the perimeter of a region of
572 % o exception: return any errors or warnings in this structure.
575 MagickExport const Quantum *GetCacheViewVirtualPixels(
576 const CacheView *cache_view,const ssize_t x,const ssize_t y,
577 const size_t columns,const size_t rows,ExceptionInfo *exception)
580 id = GetOpenMPThreadId();
585 assert(cache_view != (CacheView *) NULL);
586 assert(cache_view->signature == MagickSignature);
587 assert(id < (int) cache_view->number_threads);
588 pixels=GetVirtualPixelsFromNexus(cache_view->image,
589 cache_view->virtual_pixel_method,x,y,columns,rows,
590 cache_view->nexus_info[id],exception);
595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599 % 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 %
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
605 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
606 % location. The image background color is returned if an error occurs.
608 % The format of the GetOneCacheViewAuthenticPixel method is:
610 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
611 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
612 % Quantum *pixel,ExceptionInfo *exception)
614 % A description of each parameter follows:
616 % o cache_view: the cache view.
618 % o x,y: These values define the offset of the pixel.
620 % o pixel: return a pixel at the specified (x,y) location.
622 % o exception: return any errors or warnings in this structure.
625 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
626 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
627 ExceptionInfo *exception)
630 id = GetOpenMPThreadId();
638 assert(cache_view != (CacheView *) NULL);
639 assert(cache_view->signature == MagickSignature);
640 assert(id < (int) cache_view->number_threads);
641 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
642 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
643 cache_view->nexus_info[id],exception);
644 if (p == (const Quantum *) NULL)
646 pixel[RedPixelChannel]=cache_view->image->background_color.red;
647 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
648 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
649 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
652 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
657 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
668 % 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 %
672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
675 % location. The image background color is returned if an error occurs. If
676 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
678 % The format of the GetOneCacheViewVirtualPixel method is:
680 % MagickBooleanType GetOneCacheViewVirtualPixel(
681 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
682 % Quantum *pixel,ExceptionInfo *exception)
684 % A description of each parameter follows:
686 % o cache_view: the cache view.
688 % o x,y: These values define the offset of the pixel.
690 % o pixel: return a pixel at the specified (x,y) location.
692 % o exception: return any errors or warnings in this structure.
695 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
696 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
697 ExceptionInfo *exception)
700 id = GetOpenMPThreadId();
708 assert(cache_view != (CacheView *) NULL);
709 assert(cache_view->signature == MagickSignature);
710 assert(id < (int) cache_view->number_threads);
711 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
712 p=GetVirtualPixelsFromNexus(cache_view->image,
713 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
715 if (p == (const Quantum *) NULL)
717 pixel[RedPixelChannel]=cache_view->image->background_color.red;
718 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
719 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
720 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
723 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
728 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
739 % 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 %
743 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
745 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
746 % the specified (x,y) location. The image background color is returned if an
747 % error occurs. If you plan to modify the pixel, use
748 % GetOneCacheViewAuthenticPixel() instead.
750 % The format of the GetOneCacheViewVirtualPixel method is:
752 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
753 % const CacheView *cache_view,
754 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
755 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
757 % A description of each parameter follows:
759 % o cache_view: the cache view.
761 % o virtual_pixel_method: the virtual pixel method.
763 % o x,y: These values define the offset of the pixel.
765 % o pixel: return a pixel at the specified (x,y) location.
767 % o exception: return any errors or warnings in this structure.
770 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
771 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
772 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
775 id = GetOpenMPThreadId();
783 assert(cache_view != (CacheView *) NULL);
784 assert(cache_view->signature == MagickSignature);
785 assert(id < (int) cache_view->number_threads);
786 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
787 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
788 cache_view->nexus_info[id],exception);
789 if (p == (const Quantum *) NULL)
791 pixel[RedPixelChannel]=cache_view->image->background_color.red;
792 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
793 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
794 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
797 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
802 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
813 % 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 %
817 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
819 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
820 % disk pixel cache as defined by the geometry parameters. A pointer to the
821 % pixels is returned if the pixels are transferred, otherwise a NULL is
824 % The format of the QueueCacheViewAuthenticPixels method is:
826 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
827 % const ssize_t x,const ssize_t y,const size_t columns,
828 % const size_t rows,ExceptionInfo *exception)
830 % A description of each parameter follows:
832 % o cache_view: the cache view.
834 % o x,y,columns,rows: These values define the perimeter of a region of
837 % o exception: return any errors or warnings in this structure.
840 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
841 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
842 ExceptionInfo *exception)
845 id = GetOpenMPThreadId();
850 assert(cache_view != (CacheView *) NULL);
851 assert(cache_view->signature == MagickSignature);
852 assert(id < (int) cache_view->number_threads);
853 pixels=QueueAuthenticNexus(cache_view->image,x,y,columns,rows,MagickFalse,
854 cache_view->nexus_info[id],exception);
859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
863 % S e t C a c h e V i e w S t o r a g e C l a s s %
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 % SetCacheViewStorageClass() sets the image storage class associated with
870 % the specified view.
872 % The format of the SetCacheViewStorageClass method is:
874 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
875 % const ClassType storage_class,ExceptionInfo *exception)
877 % A description of each parameter follows:
879 % o cache_view: the cache view.
881 % o storage_class: the image storage class: PseudoClass or DirectClass.
883 % o exception: return any errors or warnings in this structure.
886 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
887 const ClassType storage_class,ExceptionInfo *exception)
889 assert(cache_view != (CacheView *) NULL);
890 assert(cache_view->signature == MagickSignature);
891 if (cache_view->debug != MagickFalse)
892 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
893 cache_view->image->filename);
894 return(SetImageStorageClass(cache_view->image,storage_class,exception));
898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902 % 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 %
906 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
908 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
909 % with the specified cache view.
911 % The format of the SetCacheViewVirtualPixelMethod method is:
913 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
914 % const VirtualPixelMethod virtual_pixel_method)
916 % A description of each parameter follows:
918 % o cache_view: the cache view.
920 % o virtual_pixel_method: the virtual pixel method.
923 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
924 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
926 assert(cache_view != (CacheView *) NULL);
927 assert(cache_view->signature == MagickSignature);
928 if (cache_view->debug != MagickFalse)
929 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
930 cache_view->image->filename);
931 cache_view->virtual_pixel_method=virtual_pixel_method;
936 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
940 % 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 %
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
946 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
947 % or disk cache. It returns MagickTrue if the pixel region is flushed,
948 % otherwise MagickFalse.
950 % The format of the SyncCacheViewAuthenticPixels method is:
952 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
953 % ExceptionInfo *exception)
955 % A description of each parameter follows:
957 % o cache_view: the cache view.
959 % o exception: return any errors or warnings in this structure.
962 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
963 CacheView *cache_view,ExceptionInfo *exception)
966 id = GetOpenMPThreadId();
971 assert(cache_view != (CacheView *) NULL);
972 assert(cache_view->signature == MagickSignature);
973 assert(id < (int) cache_view->number_threads);
974 status=SyncAuthenticPixelCacheNexus(cache_view->image,
975 cache_view->nexus_info[id],exception);