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-2013 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)
124 CatchException(exception);
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135 % A c q u i r e V i r t u a l C a c h e V i e w %
139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
142 % using the VirtualPixelMethod that is defined within the given image itself.
144 % The format of the AcquireVirtualCacheView method is:
146 % CacheView *AcquireVirtualCacheView(const Image *image,
147 % ExceptionInfo *exception)
149 % A description of each parameter follows:
151 % o image: the image.
153 % o exception: return any errors or warnings in this structure.
156 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
157 ExceptionInfo *exception)
162 assert(image != (Image *) NULL);
163 assert(image->signature == MagickSignature);
164 if (image->debug != MagickFalse)
165 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
167 cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
168 sizeof(*cache_view)));
169 if (cache_view == (CacheView *) NULL)
170 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
171 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
172 cache_view->image=ReferenceImage((Image *) image);
173 cache_view->number_threads=GetOpenMPMaximumThreads();
174 if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
175 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
176 if (cache_view->number_threads == 0)
177 cache_view->number_threads=1;
178 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
179 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
180 cache_view->debug=IsEventLogging();
181 cache_view->signature=MagickSignature;
182 if (cache_view->nexus_info == (NexusInfo **) NULL)
183 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 % C l o n e C a c h e V i e w %
196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198 % CloneCacheView() makes an exact copy of the specified cache view.
200 % The format of the CloneCacheView method is:
202 % CacheView *CloneCacheView(const CacheView *cache_view)
204 % A description of each parameter follows:
206 % o cache_view: the cache view.
209 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
214 assert(cache_view != (CacheView *) NULL);
215 assert(cache_view->signature == MagickSignature);
216 if (cache_view->debug != MagickFalse)
217 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
218 cache_view->image->filename);
219 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
220 sizeof(*clone_view)));
221 if (clone_view == (CacheView *) NULL)
222 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
223 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
224 clone_view->image=ReferenceImage(cache_view->image);
225 clone_view->number_threads=cache_view->number_threads;
226 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
227 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
228 clone_view->debug=cache_view->debug;
229 clone_view->signature=MagickSignature;
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 % D e s t r o y C a c h e V i e w %
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 % DestroyCacheView() destroys the specified view returned by a previous call
245 % to AcquireCacheView().
247 % The format of the DestroyCacheView method is:
249 % CacheView *DestroyCacheView(CacheView *cache_view)
251 % A description of each parameter follows:
253 % o cache_view: the cache view.
256 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
258 assert(cache_view != (CacheView *) NULL);
259 assert(cache_view->signature == MagickSignature);
260 if (cache_view->debug != MagickFalse)
261 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
262 cache_view->image->filename);
263 if (cache_view->nexus_info != (NexusInfo **) NULL)
264 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
265 cache_view->number_threads);
266 cache_view->image=DestroyImage(cache_view->image);
267 cache_view->signature=(~MagickSignature);
268 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277 % 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 %
281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
283 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
284 % cache as defined by the geometry parameters. A pointer to the pixels is
285 % returned if the pixels are transferred, otherwise a NULL is returned.
287 % The format of the GetCacheViewAuthenticPixels method is:
289 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
290 % const ssize_t x,const ssize_t y,const size_t columns,
291 % const size_t rows,ExceptionInfo *exception)
293 % A description of each parameter follows:
295 % o cache_view: the cache view.
297 % o x,y,columns,rows: These values define the perimeter of a region of
300 % o exception: return any errors or warnings in this structure.
303 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
304 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
305 ExceptionInfo *exception)
308 id = GetOpenMPThreadId();
313 assert(cache_view != (CacheView *) NULL);
314 assert(cache_view->signature == MagickSignature);
315 assert(id < (int) cache_view->number_threads);
316 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
317 cache_view->nexus_info[id],exception);
322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 % 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 %
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
333 % with the last call to SetCacheViewIndexes() or
334 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
337 % The format of the GetCacheViewAuthenticMetacontent() method is:
339 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
341 % A description of each parameter follows:
343 % o cache_view: the cache view.
346 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
349 id = GetOpenMPThreadId();
354 assert(cache_view != (CacheView *) NULL);
355 assert(cache_view->signature == MagickSignature);
356 assert(cache_view->image->cache != (Cache) NULL);
357 assert(id < (int) cache_view->number_threads);
358 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
359 cache_view->nexus_info[id]);
364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 % 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 %
372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
375 % last call to QueueCacheViewAuthenticPixels() or
376 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
379 % The format of the GetCacheViewAuthenticPixelQueue() method is:
381 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
383 % A description of each parameter follows:
385 % o cache_view: the cache view.
388 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
391 id = GetOpenMPThreadId();
396 assert(cache_view != (CacheView *) NULL);
397 assert(cache_view->signature == MagickSignature);
398 assert(cache_view->image->cache != (Cache) NULL);
399 assert(id < (int) cache_view->number_threads);
400 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
401 cache_view->nexus_info[id]);
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410 % G e t C a c h e V i e w C o l o r s p a c e %
414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 % GetCacheViewColorspace() returns the image colorspace associated with the
419 % The format of the GetCacheViewColorspace method is:
421 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
423 % A description of each parameter follows:
425 % o cache_view: the cache view.
428 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
430 assert(cache_view != (CacheView *) NULL);
431 assert(cache_view->signature == MagickSignature);
432 if (cache_view->debug != MagickFalse)
433 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
434 cache_view->image->filename);
435 return(GetPixelCacheColorspace(cache_view->image->cache));
439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
443 + G e t C a c h e V i e w E x t e n t %
447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
449 % GetCacheViewExtent() returns the extent of the pixels associated with the
450 % last call to QueueCacheViewAuthenticPixels() or
451 % GetCacheViewAuthenticPixels().
453 % The format of the GetCacheViewExtent() method is:
455 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
457 % A description of each parameter follows:
459 % o cache_view: the cache view.
462 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
465 id = GetOpenMPThreadId();
470 assert(cache_view != (CacheView *) NULL);
471 assert(cache_view->signature == MagickSignature);
472 if (cache_view->debug != MagickFalse)
473 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
474 cache_view->image->filename);
475 assert(cache_view->image->cache != (Cache) NULL);
476 assert(id < (int) cache_view->number_threads);
477 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
478 cache_view->nexus_info[id]);
483 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
487 % G e t C a c h e V i e w I m a g e %
491 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493 % GetCacheViewImage() returns the image associated with the specified view.
495 % The format of the GetCacheViewImage method is:
497 % const Image *GetCacheViewImage(const CacheView *cache_view)
499 % A description of each parameter follows:
501 % o cache_view: the cache view.
504 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
506 assert(cache_view != (CacheView *) NULL);
507 assert(cache_view->signature == MagickSignature);
508 if (cache_view->debug != MagickFalse)
509 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
510 cache_view->image->filename);
511 return(cache_view->image);
515 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519 % G e t C a c h e V i e w S t o r a g e C l a s s %
523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525 % GetCacheViewStorageClass() returns the image storage class associated with
526 % the specified view.
528 % The format of the GetCacheViewStorageClass method is:
530 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
532 % A description of each parameter follows:
534 % o cache_view: the cache view.
537 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
539 assert(cache_view != (CacheView *) NULL);
540 assert(cache_view->signature == MagickSignature);
541 if (cache_view->debug != MagickFalse)
542 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
543 cache_view->image->filename);
544 return(GetPixelCacheStorageClass(cache_view->image->cache));
548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
552 % 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 %
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
558 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
559 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
560 % is virtual and therefore cannot be updated.
562 % The format of the GetCacheViewVirtualMetacontent() method is:
564 % const void *GetCacheViewVirtualMetacontent(
565 % const CacheView *cache_view)
567 % A description of each parameter follows:
569 % o cache_view: the cache view.
572 MagickExport const void *GetCacheViewVirtualMetacontent(
573 const CacheView *cache_view)
576 id = GetOpenMPThreadId();
581 assert(cache_view != (const CacheView *) NULL);
582 assert(cache_view->signature == MagickSignature);
583 assert(cache_view->image->cache != (Cache) NULL);
584 assert(id < (int) cache_view->number_threads);
585 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
586 cache_view->nexus_info[id]);
591 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 % 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 %
599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
601 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
602 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
603 % and therefore cannot be updated.
605 % The format of the GetCacheViewVirtualPixelQueue() method is:
607 % const Quantum *GetCacheViewVirtualPixelQueue(
608 % const CacheView *cache_view)
610 % A description of each parameter follows:
612 % o cache_view: the cache view.
615 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
616 const CacheView *cache_view)
619 id = GetOpenMPThreadId();
624 assert(cache_view != (const CacheView *) NULL);
625 assert(cache_view->signature == MagickSignature);
626 assert(cache_view->image->cache != (Cache) NULL);
627 assert(id < (int) cache_view->number_threads);
628 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
629 cache_view->nexus_info[id]);
634 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 % 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 %
642 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
645 % disk pixel cache as defined by the geometry parameters. A pointer to the
646 % pixels is returned if the pixels are transferred, otherwise a NULL is
649 % The format of the GetCacheViewVirtualPixels method is:
651 % const Quantum *GetCacheViewVirtualPixels(
652 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
653 % const size_t columns,const size_t rows,ExceptionInfo *exception)
655 % A description of each parameter follows:
657 % o cache_view: the cache view.
659 % o x,y,columns,rows: These values define the perimeter of a region of
662 % o exception: return any errors or warnings in this structure.
665 MagickExport const Quantum *GetCacheViewVirtualPixels(
666 const CacheView *cache_view,const ssize_t x,const ssize_t y,
667 const size_t columns,const size_t rows,ExceptionInfo *exception)
670 id = GetOpenMPThreadId();
675 assert(cache_view != (CacheView *) NULL);
676 assert(cache_view->signature == MagickSignature);
677 assert(id < (int) cache_view->number_threads);
678 pixels=GetVirtualPixelsFromNexus(cache_view->image,
679 cache_view->virtual_pixel_method,x,y,columns,rows,
680 cache_view->nexus_info[id],exception);
685 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 % 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 %
693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
695 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
696 % location. The image background color is returned if an error occurs.
698 % The format of the GetOneCacheViewAuthenticPixel method is:
700 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
701 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
702 % Quantum *pixel,ExceptionInfo *exception)
704 % A description of each parameter follows:
706 % o cache_view: the cache view.
708 % o x,y: These values define the offset of the pixel.
710 % o pixel: return a pixel at the specified (x,y) location.
712 % o exception: return any errors or warnings in this structure.
715 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
716 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
717 ExceptionInfo *exception)
720 id = GetOpenMPThreadId();
728 assert(cache_view != (CacheView *) NULL);
729 assert(cache_view->signature == MagickSignature);
730 assert(id < (int) cache_view->number_threads);
731 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
732 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
733 cache_view->nexus_info[id],exception);
734 if (p == (const Quantum *) NULL)
739 background_color=cache_view->image->background_color;
740 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
741 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
742 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
743 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
744 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
747 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
752 channel=GetPixelChannelChannel(cache_view->image,i);
759 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
763 % 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 %
767 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
769 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
770 % location. The image background color is returned if an error occurs. If
771 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
773 % The format of the GetOneCacheViewVirtualPixel method is:
775 % MagickBooleanType GetOneCacheViewVirtualPixel(
776 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
777 % Quantum *pixel,ExceptionInfo *exception)
779 % A description of each parameter follows:
781 % o cache_view: the cache view.
783 % o x,y: These values define the offset of the pixel.
785 % o pixel: return a pixel at the specified (x,y) location.
787 % o exception: return any errors or warnings in this structure.
790 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
791 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
792 ExceptionInfo *exception)
795 id = GetOpenMPThreadId();
797 register const Quantum
803 assert(cache_view != (CacheView *) NULL);
804 assert(cache_view->signature == MagickSignature);
805 assert(id < (int) cache_view->number_threads);
806 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
807 p=GetVirtualPixelsFromNexus(cache_view->image,
808 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
810 if (p == (const Quantum *) NULL)
815 background_color=cache_view->image->background_color;
816 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
817 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
818 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
819 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
820 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
823 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
828 channel=GetPixelChannelChannel(cache_view->image,i);
835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
839 % 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 %
843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
845 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
846 % (x,y) location. The image background color is returned if an error occurs.
847 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
849 % The format of the GetOneCacheViewVirtualPixelInfo method is:
851 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
852 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
853 % PixelInfo *pixel,ExceptionInfo *exception)
855 % A description of each parameter follows:
857 % o cache_view: the cache view.
859 % o x,y: These values define the offset of the pixel.
861 % o pixel: return a pixel at the specified (x,y) location.
863 % o exception: return any errors or warnings in this structure.
866 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
867 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
868 ExceptionInfo *exception)
871 id = GetOpenMPThreadId();
873 register const Quantum
876 assert(cache_view != (CacheView *) NULL);
877 assert(cache_view->signature == MagickSignature);
878 assert(id < (int) cache_view->number_threads);
879 GetPixelInfo(cache_view->image,pixel);
880 p=GetVirtualPixelsFromNexus(cache_view->image,
881 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
883 if (p == (const Quantum *) NULL)
885 GetPixelInfoPixel(cache_view->image,p,pixel);
890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
894 % 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 %
898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
900 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
901 % the specified (x,y) location. The image background color is returned if an
902 % error occurs. If you plan to modify the pixel, use
903 % GetOneCacheViewAuthenticPixel() instead.
905 % The format of the GetOneCacheViewVirtualPixel method is:
907 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
908 % const CacheView *cache_view,
909 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
910 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
912 % A description of each parameter follows:
914 % o cache_view: the cache view.
916 % o virtual_pixel_method: the virtual pixel method.
918 % o x,y: These values define the offset of the pixel.
920 % o pixel: return a pixel at the specified (x,y) location.
922 % o exception: return any errors or warnings in this structure.
925 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
926 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
927 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
930 id = GetOpenMPThreadId();
938 assert(cache_view != (CacheView *) NULL);
939 assert(cache_view->signature == MagickSignature);
940 assert(id < (int) cache_view->number_threads);
941 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
942 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
943 cache_view->nexus_info[id],exception);
944 if (p == (const Quantum *) NULL)
949 background_color=cache_view->image->background_color;
950 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
951 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
952 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
953 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
954 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
957 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
962 channel=GetPixelChannelChannel(cache_view->image,i);
969 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
973 % 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 %
977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
979 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
980 % disk pixel cache as defined by the geometry parameters. A pointer to the
981 % pixels is returned if the pixels are transferred, otherwise a NULL is
984 % The format of the QueueCacheViewAuthenticPixels method is:
986 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
987 % const ssize_t x,const ssize_t y,const size_t columns,
988 % const size_t rows,ExceptionInfo *exception)
990 % A description of each parameter follows:
992 % o cache_view: the cache view.
994 % o x,y,columns,rows: These values define the perimeter of a region of
997 % o exception: return any errors or warnings in this structure.
1000 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
1001 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
1002 ExceptionInfo *exception)
1005 id = GetOpenMPThreadId();
1010 assert(cache_view != (CacheView *) NULL);
1011 assert(cache_view->signature == MagickSignature);
1012 assert(id < (int) cache_view->number_threads);
1013 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
1014 MagickFalse,cache_view->nexus_info[id],exception);
1019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1023 % S e t C a c h e V i e w S t o r a g e C l a s s %
1027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1029 % SetCacheViewStorageClass() sets the image storage class associated with
1030 % the specified view.
1032 % The format of the SetCacheViewStorageClass method is:
1034 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1035 % const ClassType storage_class,ExceptionInfo *exception)
1037 % A description of each parameter follows:
1039 % o cache_view: the cache view.
1041 % o storage_class: the image storage class: PseudoClass or DirectClass.
1043 % o exception: return any errors or warnings in this structure.
1046 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1047 const ClassType storage_class,ExceptionInfo *exception)
1049 assert(cache_view != (CacheView *) NULL);
1050 assert(cache_view->signature == MagickSignature);
1051 if (cache_view->debug != MagickFalse)
1052 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1053 cache_view->image->filename);
1054 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1062 % 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 %
1066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1068 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1069 % with the specified cache view.
1071 % The format of the SetCacheViewVirtualPixelMethod method is:
1073 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1074 % const VirtualPixelMethod virtual_pixel_method)
1076 % A description of each parameter follows:
1078 % o cache_view: the cache view.
1080 % o virtual_pixel_method: the virtual pixel method.
1083 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1084 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1086 assert(cache_view != (CacheView *) NULL);
1087 assert(cache_view->signature == MagickSignature);
1088 if (cache_view->debug != MagickFalse)
1089 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1090 cache_view->image->filename);
1091 cache_view->virtual_pixel_method=virtual_pixel_method;
1096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1100 % 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 %
1104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1106 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1107 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1108 % otherwise MagickFalse.
1110 % The format of the SyncCacheViewAuthenticPixels method is:
1112 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1113 % ExceptionInfo *exception)
1115 % A description of each parameter follows:
1117 % o cache_view: the cache view.
1119 % o exception: return any errors or warnings in this structure.
1122 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1123 CacheView *cache_view,ExceptionInfo *exception)
1126 id = GetOpenMPThreadId();
1131 assert(cache_view != (CacheView *) NULL);
1132 assert(cache_view->signature == MagickSignature);
1133 assert(id < (int) cache_view->number_threads);
1134 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1135 cache_view->nexus_info[id],exception);