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/memory-private.h"
55 #include "MagickCore/exception.h"
56 #include "MagickCore/exception-private.h"
57 #include "MagickCore/pixel-accessor.h"
58 #include "MagickCore/resource_.h"
59 #include "MagickCore/string_.h"
60 #include "MagickCore/thread-private.h"
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % 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 %
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
99 % The format of the AcquireAuthenticCacheView method is:
101 % CacheView *AcquireAuthenticCacheView(const Image *image,
102 % ExceptionInfo *exception)
104 % A description of each parameter follows:
106 % o image: the image.
108 % o exception: return any errors or warnings in this structure.
111 MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
112 ExceptionInfo *exception)
120 cache_view=AcquireVirtualCacheView(image,exception);
121 status=SyncImagePixelCache(cache_view->image,exception);
122 if (status == MagickFalse)
123 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 % A c q u i r e V i r t u a l C a c h e V i e w %
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
139 % using the VirtualPixelMethod that is defined within the given image itself.
141 % The format of the AcquireVirtualCacheView method is:
143 % CacheView *AcquireVirtualCacheView(const Image *image,
144 % ExceptionInfo *exception)
146 % A description of each parameter follows:
148 % o image: the image.
150 % o exception: return any errors or warnings in this structure.
153 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
154 ExceptionInfo *exception)
159 assert(image != (Image *) NULL);
160 assert(image->signature == MagickSignature);
161 if (image->debug != MagickFalse)
162 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
164 cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
165 sizeof(*cache_view)));
166 if (cache_view == (CacheView *) NULL)
167 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
168 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
169 cache_view->image=ReferenceImage((Image *) image);
170 cache_view->number_threads=GetOpenMPMaximumThreads();
171 if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
172 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
173 if (cache_view->number_threads == 0)
174 cache_view->number_threads=1;
175 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
176 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
177 cache_view->debug=IsEventLogging();
178 cache_view->signature=MagickSignature;
179 if (cache_view->nexus_info == (NexusInfo **) NULL)
180 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189 % C l o n e C a c h e V i e w %
193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % CloneCacheView() makes an exact copy of the specified cache view.
197 % The format of the CloneCacheView method is:
199 % CacheView *CloneCacheView(const CacheView *cache_view)
201 % A description of each parameter follows:
203 % o cache_view: the cache view.
206 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
211 assert(cache_view != (CacheView *) NULL);
212 assert(cache_view->signature == MagickSignature);
213 if (cache_view->debug != MagickFalse)
214 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
215 cache_view->image->filename);
216 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
217 sizeof(*clone_view)));
218 if (clone_view == (CacheView *) NULL)
219 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
220 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
221 clone_view->image=ReferenceImage(cache_view->image);
222 clone_view->number_threads=cache_view->number_threads;
223 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
224 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
225 clone_view->debug=cache_view->debug;
226 clone_view->signature=MagickSignature;
231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
235 % D e s t r o y C a c h e V i e w %
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241 % DestroyCacheView() destroys the specified view returned by a previous call
242 % to AcquireCacheView().
244 % The format of the DestroyCacheView method is:
246 % CacheView *DestroyCacheView(CacheView *cache_view)
248 % A description of each parameter follows:
250 % o cache_view: the cache view.
253 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
255 assert(cache_view != (CacheView *) NULL);
256 assert(cache_view->signature == MagickSignature);
257 if (cache_view->debug != MagickFalse)
258 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
259 cache_view->image->filename);
260 if (cache_view->nexus_info != (NexusInfo **) NULL)
261 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
262 cache_view->number_threads);
263 cache_view->image=DestroyImage(cache_view->image);
264 cache_view->signature=(~MagickSignature);
265 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 % 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 %
278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
281 % cache as defined by the geometry parameters. A pointer to the pixels is
282 % returned if the pixels are transferred, otherwise a NULL is returned.
284 % The format of the GetCacheViewAuthenticPixels method is:
286 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
287 % const ssize_t x,const ssize_t y,const size_t columns,
288 % const size_t rows,ExceptionInfo *exception)
290 % A description of each parameter follows:
292 % o cache_view: the cache view.
294 % o x,y,columns,rows: These values define the perimeter of a region of
297 % o exception: return any errors or warnings in this structure.
300 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
301 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
302 ExceptionInfo *exception)
305 id = GetOpenMPThreadId();
310 assert(cache_view != (CacheView *) NULL);
311 assert(cache_view->signature == MagickSignature);
312 assert(id < (int) cache_view->number_threads);
313 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
314 cache_view->nexus_info[id],exception);
319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323 % 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 %
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
330 % with the last call to SetCacheViewIndexes() or
331 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
334 % The format of the GetCacheViewAuthenticMetacontent() method is:
336 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
338 % A description of each parameter follows:
340 % o cache_view: the cache view.
343 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
346 id = GetOpenMPThreadId();
351 assert(cache_view != (CacheView *) NULL);
352 assert(cache_view->signature == MagickSignature);
353 assert(cache_view->image->cache != (Cache) NULL);
354 assert(id < (int) cache_view->number_threads);
355 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
356 cache_view->nexus_info[id]);
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365 % 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 %
369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
371 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
372 % last call to QueueCacheViewAuthenticPixels() or
373 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
376 % The format of the GetCacheViewAuthenticPixelQueue() method is:
378 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
380 % A description of each parameter follows:
382 % o cache_view: the cache view.
385 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
388 id = GetOpenMPThreadId();
393 assert(cache_view != (CacheView *) NULL);
394 assert(cache_view->signature == MagickSignature);
395 assert(cache_view->image->cache != (Cache) NULL);
396 assert(id < (int) cache_view->number_threads);
397 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
398 cache_view->nexus_info[id]);
403 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407 % G e t C a c h e V i e w C o l o r s p a c e %
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
413 % GetCacheViewColorspace() returns the image colorspace associated with the
416 % The format of the GetCacheViewColorspace method is:
418 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
420 % A description of each parameter follows:
422 % o cache_view: the cache view.
425 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
427 assert(cache_view != (CacheView *) NULL);
428 assert(cache_view->signature == MagickSignature);
429 if (cache_view->debug != MagickFalse)
430 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
431 cache_view->image->filename);
432 return(GetPixelCacheColorspace(cache_view->image->cache));
436 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
440 + G e t C a c h e V i e w E x t e n t %
444 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446 % GetCacheViewExtent() returns the extent of the pixels associated with the
447 % last call to QueueCacheViewAuthenticPixels() or
448 % GetCacheViewAuthenticPixels().
450 % The format of the GetCacheViewExtent() method is:
452 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
454 % A description of each parameter follows:
456 % o cache_view: the cache view.
459 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
462 id = GetOpenMPThreadId();
467 assert(cache_view != (CacheView *) NULL);
468 assert(cache_view->signature == MagickSignature);
469 if (cache_view->debug != MagickFalse)
470 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
471 cache_view->image->filename);
472 assert(cache_view->image->cache != (Cache) NULL);
473 assert(id < (int) cache_view->number_threads);
474 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
475 cache_view->nexus_info[id]);
480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
484 % G e t C a c h e V i e w I m a g e %
488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490 % GetCacheViewImage() returns the image associated with the specified view.
492 % The format of the GetCacheViewImage method is:
494 % const Image *GetCacheViewImage(const CacheView *cache_view)
496 % A description of each parameter follows:
498 % o cache_view: the cache view.
501 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
503 assert(cache_view != (CacheView *) NULL);
504 assert(cache_view->signature == MagickSignature);
505 if (cache_view->debug != MagickFalse)
506 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
507 cache_view->image->filename);
508 return(cache_view->image);
512 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
516 % G e t C a c h e V i e w S t o r a g e C l a s s %
520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
522 % GetCacheViewStorageClass() returns the image storage class associated with
523 % the specified view.
525 % The format of the GetCacheViewStorageClass method is:
527 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
529 % A description of each parameter follows:
531 % o cache_view: the cache view.
534 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
536 assert(cache_view != (CacheView *) NULL);
537 assert(cache_view->signature == MagickSignature);
538 if (cache_view->debug != MagickFalse)
539 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
540 cache_view->image->filename);
541 return(GetPixelCacheStorageClass(cache_view->image->cache));
545 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549 % 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 %
553 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
556 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
557 % is virtual and therefore cannot be updated.
559 % The format of the GetCacheViewVirtualMetacontent() method is:
561 % const void *GetCacheViewVirtualMetacontent(
562 % const CacheView *cache_view)
564 % A description of each parameter follows:
566 % o cache_view: the cache view.
569 MagickExport const void *GetCacheViewVirtualMetacontent(
570 const CacheView *cache_view)
573 id = GetOpenMPThreadId();
578 assert(cache_view != (const CacheView *) NULL);
579 assert(cache_view->signature == MagickSignature);
580 assert(cache_view->image->cache != (Cache) NULL);
581 assert(id < (int) cache_view->number_threads);
582 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
583 cache_view->nexus_info[id]);
588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
592 % 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 %
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
599 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
600 % and therefore cannot be updated.
602 % The format of the GetCacheViewVirtualPixelQueue() method is:
604 % const Quantum *GetCacheViewVirtualPixelQueue(
605 % const CacheView *cache_view)
607 % A description of each parameter follows:
609 % o cache_view: the cache view.
612 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
613 const CacheView *cache_view)
616 id = GetOpenMPThreadId();
621 assert(cache_view != (const CacheView *) NULL);
622 assert(cache_view->signature == MagickSignature);
623 assert(cache_view->image->cache != (Cache) NULL);
624 assert(id < (int) cache_view->number_threads);
625 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
626 cache_view->nexus_info[id]);
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635 % 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 %
639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
641 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
642 % disk pixel cache as defined by the geometry parameters. A pointer to the
643 % pixels is returned if the pixels are transferred, otherwise a NULL is
646 % The format of the GetCacheViewVirtualPixels method is:
648 % const Quantum *GetCacheViewVirtualPixels(
649 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
650 % const size_t columns,const size_t rows,ExceptionInfo *exception)
652 % A description of each parameter follows:
654 % o cache_view: the cache view.
656 % o x,y,columns,rows: These values define the perimeter of a region of
659 % o exception: return any errors or warnings in this structure.
662 MagickExport const Quantum *GetCacheViewVirtualPixels(
663 const CacheView *cache_view,const ssize_t x,const ssize_t y,
664 const size_t columns,const size_t rows,ExceptionInfo *exception)
667 id = GetOpenMPThreadId();
672 assert(cache_view != (CacheView *) NULL);
673 assert(cache_view->signature == MagickSignature);
674 assert(id < (int) cache_view->number_threads);
675 pixels=GetVirtualPixelsFromNexus(cache_view->image,
676 cache_view->virtual_pixel_method,x,y,columns,rows,
677 cache_view->nexus_info[id],exception);
682 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
686 % 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 %
690 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
693 % location. The image background color is returned if an error occurs.
695 % The format of the GetOneCacheViewAuthenticPixel method is:
697 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
698 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
699 % Quantum *pixel,ExceptionInfo *exception)
701 % A description of each parameter follows:
703 % o cache_view: the cache view.
705 % o x,y: These values define the offset of the pixel.
707 % o pixel: return a pixel at the specified (x,y) location.
709 % o exception: return any errors or warnings in this structure.
712 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
713 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
714 ExceptionInfo *exception)
717 id = GetOpenMPThreadId();
725 assert(cache_view != (CacheView *) NULL);
726 assert(cache_view->signature == MagickSignature);
727 assert(id < (int) cache_view->number_threads);
728 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
729 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
730 cache_view->nexus_info[id],exception);
731 if (p == (const Quantum *) NULL)
736 background_color=cache_view->image->background_color;
737 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
738 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
739 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
740 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
741 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
744 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
749 channel=GetPixelChannelChannel(cache_view->image,i);
756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
760 % 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 %
764 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
766 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
767 % location. The image background color is returned if an error occurs. If
768 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
770 % The format of the GetOneCacheViewVirtualPixel method is:
772 % MagickBooleanType GetOneCacheViewVirtualPixel(
773 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
774 % Quantum *pixel,ExceptionInfo *exception)
776 % A description of each parameter follows:
778 % o cache_view: the cache view.
780 % o x,y: These values define the offset of the pixel.
782 % o pixel: return a pixel at the specified (x,y) location.
784 % o exception: return any errors or warnings in this structure.
787 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
788 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
789 ExceptionInfo *exception)
792 id = GetOpenMPThreadId();
794 register const Quantum
800 assert(cache_view != (CacheView *) NULL);
801 assert(cache_view->signature == MagickSignature);
802 assert(id < (int) cache_view->number_threads);
803 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
804 p=GetVirtualPixelsFromNexus(cache_view->image,
805 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
807 if (p == (const Quantum *) NULL)
812 background_color=cache_view->image->background_color;
813 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
814 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
815 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
816 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
817 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
820 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
825 channel=GetPixelChannelChannel(cache_view->image,i);
832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
836 % 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 %
840 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
842 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
843 % (x,y) location. The image background color is returned if an error occurs.
844 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
846 % The format of the GetOneCacheViewVirtualPixelInfo method is:
848 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
849 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
850 % PixelInfo *pixel,ExceptionInfo *exception)
852 % A description of each parameter follows:
854 % o cache_view: the cache view.
856 % o x,y: These values define the offset of the pixel.
858 % o pixel: return a pixel at the specified (x,y) location.
860 % o exception: return any errors or warnings in this structure.
863 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
864 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
865 ExceptionInfo *exception)
868 id = GetOpenMPThreadId();
870 register const Quantum
873 assert(cache_view != (CacheView *) NULL);
874 assert(cache_view->signature == MagickSignature);
875 assert(id < (int) cache_view->number_threads);
876 GetPixelInfo(cache_view->image,pixel);
877 p=GetVirtualPixelsFromNexus(cache_view->image,
878 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
880 if (p == (const Quantum *) NULL)
882 GetPixelInfoPixel(cache_view->image,p,pixel);
887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
891 % 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 %
895 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
897 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
898 % the specified (x,y) location. The image background color is returned if an
899 % error occurs. If you plan to modify the pixel, use
900 % GetOneCacheViewAuthenticPixel() instead.
902 % The format of the GetOneCacheViewVirtualPixel method is:
904 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
905 % const CacheView *cache_view,
906 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
907 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
909 % A description of each parameter follows:
911 % o cache_view: the cache view.
913 % o virtual_pixel_method: the virtual pixel method.
915 % o x,y: These values define the offset of the pixel.
917 % o pixel: return a pixel at the specified (x,y) location.
919 % o exception: return any errors or warnings in this structure.
922 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
923 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
924 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
927 id = GetOpenMPThreadId();
935 assert(cache_view != (CacheView *) NULL);
936 assert(cache_view->signature == MagickSignature);
937 assert(id < (int) cache_view->number_threads);
938 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
939 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
940 cache_view->nexus_info[id],exception);
941 if (p == (const Quantum *) NULL)
946 background_color=cache_view->image->background_color;
947 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
948 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
949 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
950 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
951 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
954 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
959 channel=GetPixelChannelChannel(cache_view->image,i);
966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
970 % 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 %
974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
977 % disk pixel cache as defined by the geometry parameters. A pointer to the
978 % pixels is returned if the pixels are transferred, otherwise a NULL is
981 % The format of the QueueCacheViewAuthenticPixels method is:
983 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
984 % const ssize_t x,const ssize_t y,const size_t columns,
985 % const size_t rows,ExceptionInfo *exception)
987 % A description of each parameter follows:
989 % o cache_view: the cache view.
991 % o x,y,columns,rows: These values define the perimeter of a region of
994 % o exception: return any errors or warnings in this structure.
997 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
998 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
999 ExceptionInfo *exception)
1002 id = GetOpenMPThreadId();
1007 assert(cache_view != (CacheView *) NULL);
1008 assert(cache_view->signature == MagickSignature);
1009 assert(id < (int) cache_view->number_threads);
1010 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
1011 MagickFalse,cache_view->nexus_info[id],exception);
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020 % S e t C a c h e V i e w S t o r a g e C l a s s %
1024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1026 % SetCacheViewStorageClass() sets the image storage class associated with
1027 % the specified view.
1029 % The format of the SetCacheViewStorageClass method is:
1031 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1032 % const ClassType storage_class,ExceptionInfo *exception)
1034 % A description of each parameter follows:
1036 % o cache_view: the cache view.
1038 % o storage_class: the image storage class: PseudoClass or DirectClass.
1040 % o exception: return any errors or warnings in this structure.
1043 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1044 const ClassType storage_class,ExceptionInfo *exception)
1046 assert(cache_view != (CacheView *) NULL);
1047 assert(cache_view->signature == MagickSignature);
1048 if (cache_view->debug != MagickFalse)
1049 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1050 cache_view->image->filename);
1051 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1055 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1059 % 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 %
1063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1065 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1066 % with the specified cache view.
1068 % The format of the SetCacheViewVirtualPixelMethod method is:
1070 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1071 % const VirtualPixelMethod virtual_pixel_method)
1073 % A description of each parameter follows:
1075 % o cache_view: the cache view.
1077 % o virtual_pixel_method: the virtual pixel method.
1080 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1081 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1083 assert(cache_view != (CacheView *) NULL);
1084 assert(cache_view->signature == MagickSignature);
1085 if (cache_view->debug != MagickFalse)
1086 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1087 cache_view->image->filename);
1088 cache_view->virtual_pixel_method=virtual_pixel_method;
1093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1097 % 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 %
1101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1103 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1104 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1105 % otherwise MagickFalse.
1107 % The format of the SyncCacheViewAuthenticPixels method is:
1109 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1110 % ExceptionInfo *exception)
1112 % A description of each parameter follows:
1114 % o cache_view: the cache view.
1116 % o exception: return any errors or warnings in this structure.
1119 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1120 CacheView *cache_view,ExceptionInfo *exception)
1123 id = GetOpenMPThreadId();
1128 assert(cache_view != (CacheView *) NULL);
1129 assert(cache_view->signature == MagickSignature);
1130 assert(id < (int) cache_view->number_threads);
1131 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1132 cache_view->nexus_info[id],exception);