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.
98 % It always succeeds but may return a warning or informational exception.
100 % The format of the AcquireAuthenticCacheView method is:
102 % CacheView *AcquireAuthenticCacheView(const Image *image,
103 % ExceptionInfo *exception)
105 % A description of each parameter follows:
107 % o image: the image.
109 % o exception: return any errors or warnings in this structure.
112 MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
113 ExceptionInfo *exception)
118 cache_view=AcquireVirtualCacheView(image,exception);
119 (void) SyncImagePixelCache(cache_view->image,exception);
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 % A c q u i r e V i r t u a l C a c h e V i e w %
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
135 % using the VirtualPixelMethod that is defined within the given image itself.
136 % It always succeeds but may return a warning or informational exception.
138 % The format of the AcquireVirtualCacheView method is:
140 % CacheView *AcquireVirtualCacheView(const Image *image,
141 % ExceptionInfo *exception)
143 % A description of each parameter follows:
145 % o image: the image.
147 % o exception: return any errors or warnings in this structure.
150 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
151 ExceptionInfo *exception)
156 assert(image != (Image *) NULL);
157 assert(image->signature == MagickSignature);
158 if (image->debug != MagickFalse)
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
161 cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
162 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 if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
169 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
170 if (cache_view->number_threads == 0)
171 cache_view->number_threads=1;
172 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
173 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
174 cache_view->debug=IsEventLogging();
175 cache_view->signature=MagickSignature;
176 if (cache_view->nexus_info == (NexusInfo **) NULL)
177 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 % C l o n e C a c h e V i e w %
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 % CloneCacheView() makes an exact copy of the specified cache view.
194 % The format of the CloneCacheView method is:
196 % CacheView *CloneCacheView(const CacheView *cache_view)
198 % A description of each parameter follows:
200 % o cache_view: the cache view.
203 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
208 assert(cache_view != (CacheView *) NULL);
209 assert(cache_view->signature == MagickSignature);
210 if (cache_view->debug != MagickFalse)
211 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
212 cache_view->image->filename);
213 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
214 sizeof(*clone_view)));
215 if (clone_view == (CacheView *) NULL)
216 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
217 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
218 clone_view->image=ReferenceImage(cache_view->image);
219 clone_view->number_threads=cache_view->number_threads;
220 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
221 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
222 clone_view->debug=cache_view->debug;
223 clone_view->signature=MagickSignature;
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 % D e s t r o y C a c h e V i e w %
236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238 % DestroyCacheView() destroys the specified view returned by a previous call
239 % to AcquireCacheView().
241 % The format of the DestroyCacheView method is:
243 % CacheView *DestroyCacheView(CacheView *cache_view)
245 % A description of each parameter follows:
247 % o cache_view: the cache view.
250 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
252 assert(cache_view != (CacheView *) NULL);
253 assert(cache_view->signature == MagickSignature);
254 if (cache_view->debug != MagickFalse)
255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
256 cache_view->image->filename);
257 if (cache_view->nexus_info != (NexusInfo **) NULL)
258 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
259 cache_view->number_threads);
260 cache_view->image=DestroyImage(cache_view->image);
261 cache_view->signature=(~MagickSignature);
262 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 % 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 %
275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
278 % cache as defined by the geometry parameters. A pointer to the pixels is
279 % returned if the pixels are transferred, otherwise a NULL is returned.
281 % The format of the GetCacheViewAuthenticPixels method is:
283 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
284 % const ssize_t x,const ssize_t y,const size_t columns,
285 % const size_t rows,ExceptionInfo *exception)
287 % A description of each parameter follows:
289 % o cache_view: the cache view.
291 % o x,y,columns,rows: These values define the perimeter of a region of
294 % o exception: return any errors or warnings in this structure.
297 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
298 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
299 ExceptionInfo *exception)
302 id = GetOpenMPThreadId();
307 assert(cache_view != (CacheView *) NULL);
308 assert(cache_view->signature == MagickSignature);
309 assert(id < (int) cache_view->number_threads);
310 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
311 cache_view->nexus_info[id],exception);
316 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 % 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 %
324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
327 % with the last call to SetCacheViewIndexes() or
328 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
331 % The format of the GetCacheViewAuthenticMetacontent() method is:
333 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
335 % A description of each parameter follows:
337 % o cache_view: the cache view.
340 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
343 id = GetOpenMPThreadId();
348 assert(cache_view != (CacheView *) NULL);
349 assert(cache_view->signature == MagickSignature);
350 assert(cache_view->image->cache != (Cache) NULL);
351 assert(id < (int) cache_view->number_threads);
352 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
353 cache_view->nexus_info[id]);
358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % 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 %
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
369 % last call to QueueCacheViewAuthenticPixels() or
370 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
373 % The format of the GetCacheViewAuthenticPixelQueue() method is:
375 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
377 % A description of each parameter follows:
379 % o cache_view: the cache view.
382 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
385 id = GetOpenMPThreadId();
390 assert(cache_view != (CacheView *) NULL);
391 assert(cache_view->signature == MagickSignature);
392 assert(cache_view->image->cache != (Cache) NULL);
393 assert(id < (int) cache_view->number_threads);
394 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
395 cache_view->nexus_info[id]);
400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404 % G e t C a c h e V i e w C o l o r s p a c e %
408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410 % GetCacheViewColorspace() returns the image colorspace associated with the
413 % The format of the GetCacheViewColorspace method is:
415 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
417 % A description of each parameter follows:
419 % o cache_view: the cache view.
422 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
424 assert(cache_view != (CacheView *) NULL);
425 assert(cache_view->signature == MagickSignature);
426 if (cache_view->debug != MagickFalse)
427 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
428 cache_view->image->filename);
429 return(GetPixelCacheColorspace(cache_view->image->cache));
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
437 + G e t C a c h e V i e w E x t e n t %
441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
443 % GetCacheViewExtent() returns the extent of the pixels associated with the
444 % last call to QueueCacheViewAuthenticPixels() or
445 % GetCacheViewAuthenticPixels().
447 % The format of the GetCacheViewExtent() method is:
449 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
451 % A description of each parameter follows:
453 % o cache_view: the cache view.
456 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
459 id = GetOpenMPThreadId();
464 assert(cache_view != (CacheView *) NULL);
465 assert(cache_view->signature == MagickSignature);
466 if (cache_view->debug != MagickFalse)
467 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
468 cache_view->image->filename);
469 assert(cache_view->image->cache != (Cache) NULL);
470 assert(id < (int) cache_view->number_threads);
471 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
472 cache_view->nexus_info[id]);
477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481 % G e t C a c h e V i e w I m a g e %
485 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
487 % GetCacheViewImage() returns the image associated with the specified view.
489 % The format of the GetCacheViewImage method is:
491 % const Image *GetCacheViewImage(const CacheView *cache_view)
493 % A description of each parameter follows:
495 % o cache_view: the cache view.
498 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
500 assert(cache_view != (CacheView *) NULL);
501 assert(cache_view->signature == MagickSignature);
502 if (cache_view->debug != MagickFalse)
503 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
504 cache_view->image->filename);
505 return(cache_view->image);
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 % G e t C a c h e V i e w S t o r a g e C l a s s %
517 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
519 % GetCacheViewStorageClass() returns the image storage class associated with
520 % the specified view.
522 % The format of the GetCacheViewStorageClass method is:
524 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
526 % A description of each parameter follows:
528 % o cache_view: the cache view.
531 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
533 assert(cache_view != (CacheView *) NULL);
534 assert(cache_view->signature == MagickSignature);
535 if (cache_view->debug != MagickFalse)
536 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
537 cache_view->image->filename);
538 return(GetPixelCacheStorageClass(cache_view->image->cache));
542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
546 % 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 %
550 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
552 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
553 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
554 % is virtual and therefore cannot be updated.
556 % The format of the GetCacheViewVirtualMetacontent() method is:
558 % const void *GetCacheViewVirtualMetacontent(
559 % const CacheView *cache_view)
561 % A description of each parameter follows:
563 % o cache_view: the cache view.
566 MagickExport const void *GetCacheViewVirtualMetacontent(
567 const CacheView *cache_view)
570 id = GetOpenMPThreadId();
575 assert(cache_view != (const CacheView *) NULL);
576 assert(cache_view->signature == MagickSignature);
577 assert(cache_view->image->cache != (Cache) NULL);
578 assert(id < (int) cache_view->number_threads);
579 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
580 cache_view->nexus_info[id]);
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589 % 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 %
593 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
596 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
597 % and therefore cannot be updated.
599 % The format of the GetCacheViewVirtualPixelQueue() method is:
601 % const Quantum *GetCacheViewVirtualPixelQueue(
602 % const CacheView *cache_view)
604 % A description of each parameter follows:
606 % o cache_view: the cache view.
609 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
610 const CacheView *cache_view)
613 id = GetOpenMPThreadId();
618 assert(cache_view != (const CacheView *) NULL);
619 assert(cache_view->signature == MagickSignature);
620 assert(cache_view->image->cache != (Cache) NULL);
621 assert(id < (int) cache_view->number_threads);
622 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
623 cache_view->nexus_info[id]);
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
632 % 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 %
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
639 % disk pixel cache as defined by the geometry parameters. A pointer to the
640 % pixels is returned if the pixels are transferred, otherwise a NULL is
643 % The format of the GetCacheViewVirtualPixels method is:
645 % const Quantum *GetCacheViewVirtualPixels(
646 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
647 % const size_t columns,const size_t rows,ExceptionInfo *exception)
649 % A description of each parameter follows:
651 % o cache_view: the cache view.
653 % o x,y,columns,rows: These values define the perimeter of a region of
656 % o exception: return any errors or warnings in this structure.
659 MagickExport const Quantum *GetCacheViewVirtualPixels(
660 const CacheView *cache_view,const ssize_t x,const ssize_t y,
661 const size_t columns,const size_t rows,ExceptionInfo *exception)
664 id = GetOpenMPThreadId();
669 assert(cache_view != (CacheView *) NULL);
670 assert(cache_view->signature == MagickSignature);
671 assert(id < (int) cache_view->number_threads);
672 pixels=GetVirtualPixelsFromNexus(cache_view->image,
673 cache_view->virtual_pixel_method,x,y,columns,rows,
674 cache_view->nexus_info[id],exception);
679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
683 % 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 %
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
689 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
690 % location. The image background color is returned if an error occurs.
692 % The format of the GetOneCacheViewAuthenticPixel method is:
694 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
695 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
696 % Quantum *pixel,ExceptionInfo *exception)
698 % A description of each parameter follows:
700 % o cache_view: the cache view.
702 % o x,y: These values define the offset of the pixel.
704 % o pixel: return a pixel at the specified (x,y) location.
706 % o exception: return any errors or warnings in this structure.
709 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
710 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
711 ExceptionInfo *exception)
714 id = GetOpenMPThreadId();
722 assert(cache_view != (CacheView *) NULL);
723 assert(cache_view->signature == MagickSignature);
724 assert(id < (int) cache_view->number_threads);
725 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
726 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
727 cache_view->nexus_info[id],exception);
728 if (p == (const Quantum *) NULL)
733 background_color=cache_view->image->background_color;
734 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
735 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
736 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
737 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
738 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
741 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
746 channel=GetPixelChannelChannel(cache_view->image,i);
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
757 % 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 %
761 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
763 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
764 % location. The image background color is returned if an error occurs. If
765 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
767 % The format of the GetOneCacheViewVirtualPixel method is:
769 % MagickBooleanType GetOneCacheViewVirtualPixel(
770 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
771 % Quantum *pixel,ExceptionInfo *exception)
773 % A description of each parameter follows:
775 % o cache_view: the cache view.
777 % o x,y: These values define the offset of the pixel.
779 % o pixel: return a pixel at the specified (x,y) location.
781 % o exception: return any errors or warnings in this structure.
784 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
785 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
786 ExceptionInfo *exception)
789 id = GetOpenMPThreadId();
791 register const Quantum
797 assert(cache_view != (CacheView *) NULL);
798 assert(cache_view->signature == MagickSignature);
799 assert(id < (int) cache_view->number_threads);
800 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
801 p=GetVirtualPixelsFromNexus(cache_view->image,
802 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
804 if (p == (const Quantum *) NULL)
809 background_color=cache_view->image->background_color;
810 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
811 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
812 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
813 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
814 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
817 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
822 channel=GetPixelChannelChannel(cache_view->image,i);
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 % 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 %
837 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
839 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
840 % (x,y) location. The image background color is returned if an error occurs.
841 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
843 % The format of the GetOneCacheViewVirtualPixelInfo method is:
845 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
846 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
847 % PixelInfo *pixel,ExceptionInfo *exception)
849 % A description of each parameter follows:
851 % o cache_view: the cache view.
853 % o x,y: These values define the offset of the pixel.
855 % o pixel: return a pixel at the specified (x,y) location.
857 % o exception: return any errors or warnings in this structure.
860 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
861 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
862 ExceptionInfo *exception)
865 id = GetOpenMPThreadId();
867 register const Quantum
870 assert(cache_view != (CacheView *) NULL);
871 assert(cache_view->signature == MagickSignature);
872 assert(id < (int) cache_view->number_threads);
873 GetPixelInfo(cache_view->image,pixel);
874 p=GetVirtualPixelsFromNexus(cache_view->image,
875 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
877 if (p == (const Quantum *) NULL)
879 GetPixelInfoPixel(cache_view->image,p,pixel);
884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
888 % 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 %
892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
894 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
895 % the specified (x,y) location. The image background color is returned if an
896 % error occurs. If you plan to modify the pixel, use
897 % GetOneCacheViewAuthenticPixel() instead.
899 % The format of the GetOneCacheViewVirtualPixel method is:
901 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
902 % const CacheView *cache_view,
903 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
904 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
906 % A description of each parameter follows:
908 % o cache_view: the cache view.
910 % o virtual_pixel_method: the virtual pixel method.
912 % o x,y: These values define the offset of the pixel.
914 % o pixel: return a pixel at the specified (x,y) location.
916 % o exception: return any errors or warnings in this structure.
919 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
920 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
921 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
924 id = GetOpenMPThreadId();
932 assert(cache_view != (CacheView *) NULL);
933 assert(cache_view->signature == MagickSignature);
934 assert(id < (int) cache_view->number_threads);
935 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
936 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
937 cache_view->nexus_info[id],exception);
938 if (p == (const Quantum *) NULL)
943 background_color=cache_view->image->background_color;
944 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
945 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
946 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
947 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
948 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
951 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
956 channel=GetPixelChannelChannel(cache_view->image,i);
963 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
967 % 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 %
971 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
973 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
974 % disk pixel cache as defined by the geometry parameters. A pointer to the
975 % pixels is returned if the pixels are transferred, otherwise a NULL is
978 % The format of the QueueCacheViewAuthenticPixels method is:
980 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
981 % const ssize_t x,const ssize_t y,const size_t columns,
982 % const size_t rows,ExceptionInfo *exception)
984 % A description of each parameter follows:
986 % o cache_view: the cache view.
988 % o x,y,columns,rows: These values define the perimeter of a region of
991 % o exception: return any errors or warnings in this structure.
994 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
995 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
996 ExceptionInfo *exception)
999 id = GetOpenMPThreadId();
1004 assert(cache_view != (CacheView *) NULL);
1005 assert(cache_view->signature == MagickSignature);
1006 assert(id < (int) cache_view->number_threads);
1007 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
1008 MagickFalse,cache_view->nexus_info[id],exception);
1013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1017 % S e t C a c h e V i e w S t o r a g e C l a s s %
1021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1023 % SetCacheViewStorageClass() sets the image storage class associated with
1024 % the specified view.
1026 % The format of the SetCacheViewStorageClass method is:
1028 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1029 % const ClassType storage_class,ExceptionInfo *exception)
1031 % A description of each parameter follows:
1033 % o cache_view: the cache view.
1035 % o storage_class: the image storage class: PseudoClass or DirectClass.
1037 % o exception: return any errors or warnings in this structure.
1040 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1041 const ClassType storage_class,ExceptionInfo *exception)
1043 assert(cache_view != (CacheView *) NULL);
1044 assert(cache_view->signature == MagickSignature);
1045 if (cache_view->debug != MagickFalse)
1046 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1047 cache_view->image->filename);
1048 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1056 % 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 %
1060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1062 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1063 % with the specified cache view.
1065 % The format of the SetCacheViewVirtualPixelMethod method is:
1067 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1068 % const VirtualPixelMethod virtual_pixel_method)
1070 % A description of each parameter follows:
1072 % o cache_view: the cache view.
1074 % o virtual_pixel_method: the virtual pixel method.
1077 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1078 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1080 assert(cache_view != (CacheView *) NULL);
1081 assert(cache_view->signature == MagickSignature);
1082 if (cache_view->debug != MagickFalse)
1083 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1084 cache_view->image->filename);
1085 cache_view->virtual_pixel_method=virtual_pixel_method;
1090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1094 % 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 %
1098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1100 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1101 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1102 % otherwise MagickFalse.
1104 % The format of the SyncCacheViewAuthenticPixels method is:
1106 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1107 % ExceptionInfo *exception)
1109 % A description of each parameter follows:
1111 % o cache_view: the cache view.
1113 % o exception: return any errors or warnings in this structure.
1116 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1117 CacheView *cache_view,ExceptionInfo *exception)
1120 id = GetOpenMPThreadId();
1125 assert(cache_view != (CacheView *) NULL);
1126 assert(cache_view->signature == MagickSignature);
1127 assert(id < (int) cache_view->number_threads);
1128 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1129 cache_view->nexus_info[id],exception);