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=(size_t) GetMagickResourceLimit(ThreadResource);
171 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
172 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
173 cache_view->debug=IsEventLogging();
174 cache_view->signature=MagickSignature;
175 if (cache_view->nexus_info == (NexusInfo **) NULL)
176 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185 % C l o n e C a c h e V i e w %
189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191 % CloneCacheView() makes an exact copy of the specified cache view.
193 % The format of the CloneCacheView method is:
195 % CacheView *CloneCacheView(const CacheView *cache_view)
197 % A description of each parameter follows:
199 % o cache_view: the cache view.
202 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
207 assert(cache_view != (CacheView *) NULL);
208 assert(cache_view->signature == MagickSignature);
209 if (cache_view->debug != MagickFalse)
210 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
211 cache_view->image->filename);
212 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
213 sizeof(*clone_view)));
214 if (clone_view == (CacheView *) NULL)
215 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
216 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
217 clone_view->image=ReferenceImage(cache_view->image);
218 clone_view->number_threads=cache_view->number_threads;
219 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
220 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
221 clone_view->debug=cache_view->debug;
222 clone_view->signature=MagickSignature;
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 % D e s t r o y C a c h e V i e w %
235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237 % DestroyCacheView() destroys the specified view returned by a previous call
238 % to AcquireCacheView().
240 % The format of the DestroyCacheView method is:
242 % CacheView *DestroyCacheView(CacheView *cache_view)
244 % A description of each parameter follows:
246 % o cache_view: the cache view.
249 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
251 assert(cache_view != (CacheView *) NULL);
252 assert(cache_view->signature == MagickSignature);
253 if (cache_view->debug != MagickFalse)
254 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
255 cache_view->image->filename);
256 if (cache_view->nexus_info != (NexusInfo **) NULL)
257 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
258 cache_view->number_threads);
259 cache_view->image=DestroyImage(cache_view->image);
260 cache_view->signature=(~MagickSignature);
261 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270 % 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 %
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
277 % cache as defined by the geometry parameters. A pointer to the pixels is
278 % returned if the pixels are transferred, otherwise a NULL is returned.
280 % The format of the GetCacheViewAuthenticPixels method is:
282 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
283 % const ssize_t x,const ssize_t y,const size_t columns,
284 % const size_t rows,ExceptionInfo *exception)
286 % A description of each parameter follows:
288 % o cache_view: the cache view.
290 % o x,y,columns,rows: These values define the perimeter of a region of
293 % o exception: return any errors or warnings in this structure.
296 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
297 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
298 ExceptionInfo *exception)
301 id = GetOpenMPThreadId();
306 assert(cache_view != (CacheView *) NULL);
307 assert(cache_view->signature == MagickSignature);
308 assert(id < (int) cache_view->number_threads);
309 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
310 cache_view->nexus_info[id],exception);
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319 % 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 %
323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
326 % with the last call to SetCacheViewIndexes() or
327 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
330 % The format of the GetCacheViewAuthenticMetacontent() method is:
332 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
334 % A description of each parameter follows:
336 % o cache_view: the cache view.
339 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
342 id = GetOpenMPThreadId();
347 assert(cache_view != (CacheView *) NULL);
348 assert(cache_view->signature == MagickSignature);
349 assert(cache_view->image->cache != (Cache) NULL);
350 assert(id < (int) cache_view->number_threads);
351 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
352 cache_view->nexus_info[id]);
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
361 % 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 %
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
368 % last call to QueueCacheViewAuthenticPixels() or
369 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
372 % The format of the GetCacheViewAuthenticPixelQueue() method is:
374 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
376 % A description of each parameter follows:
378 % o cache_view: the cache view.
381 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
384 id = GetOpenMPThreadId();
389 assert(cache_view != (CacheView *) NULL);
390 assert(cache_view->signature == MagickSignature);
391 assert(cache_view->image->cache != (Cache) NULL);
392 assert(id < (int) cache_view->number_threads);
393 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
394 cache_view->nexus_info[id]);
399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 % G e t C a c h e V i e w C o l o r s p a c e %
407 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 % GetCacheViewColorspace() returns the image colorspace associated with the
412 % The format of the GetCacheViewColorspace method is:
414 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
416 % A description of each parameter follows:
418 % o cache_view: the cache view.
421 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
423 assert(cache_view != (CacheView *) NULL);
424 assert(cache_view->signature == MagickSignature);
425 if (cache_view->debug != MagickFalse)
426 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
427 cache_view->image->filename);
428 return(GetPixelCacheColorspace(cache_view->image->cache));
432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
436 + G e t C a c h e V i e w E x t e n t %
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442 % GetCacheViewExtent() returns the extent of the pixels associated with the
443 % last call to QueueCacheViewAuthenticPixels() or
444 % GetCacheViewAuthenticPixels().
446 % The format of the GetCacheViewExtent() method is:
448 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
450 % A description of each parameter follows:
452 % o cache_view: the cache view.
455 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
458 id = GetOpenMPThreadId();
463 assert(cache_view != (CacheView *) NULL);
464 assert(cache_view->signature == MagickSignature);
465 if (cache_view->debug != MagickFalse)
466 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
467 cache_view->image->filename);
468 assert(cache_view->image->cache != (Cache) NULL);
469 assert(id < (int) cache_view->number_threads);
470 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
471 cache_view->nexus_info[id]);
476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480 % G e t C a c h e V i e w I m a g e %
484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
486 % GetCacheViewImage() returns the image associated with the specified view.
488 % The format of the GetCacheViewImage method is:
490 % const Image *GetCacheViewImage(const CacheView *cache_view)
492 % A description of each parameter follows:
494 % o cache_view: the cache view.
497 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
499 assert(cache_view != (CacheView *) NULL);
500 assert(cache_view->signature == MagickSignature);
501 if (cache_view->debug != MagickFalse)
502 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
503 cache_view->image->filename);
504 return(cache_view->image);
508 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
512 % G e t C a c h e V i e w S t o r a g e C l a s s %
516 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
518 % GetCacheViewStorageClass() returns the image storage class associated with
519 % the specified view.
521 % The format of the GetCacheViewStorageClass method is:
523 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
525 % A description of each parameter follows:
527 % o cache_view: the cache view.
530 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
532 assert(cache_view != (CacheView *) NULL);
533 assert(cache_view->signature == MagickSignature);
534 if (cache_view->debug != MagickFalse)
535 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
536 cache_view->image->filename);
537 return(GetPixelCacheStorageClass(cache_view->image->cache));
541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
545 % 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 %
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
551 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
552 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
553 % is virtual and therefore cannot be updated.
555 % The format of the GetCacheViewVirtualMetacontent() method is:
557 % const void *GetCacheViewVirtualMetacontent(
558 % const CacheView *cache_view)
560 % A description of each parameter follows:
562 % o cache_view: the cache view.
565 MagickExport const void *GetCacheViewVirtualMetacontent(
566 const CacheView *cache_view)
569 id = GetOpenMPThreadId();
574 assert(cache_view != (const CacheView *) NULL);
575 assert(cache_view->signature == MagickSignature);
576 assert(cache_view->image->cache != (Cache) NULL);
577 assert(id < (int) cache_view->number_threads);
578 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
579 cache_view->nexus_info[id]);
584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588 % 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 %
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
594 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
595 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
596 % and therefore cannot be updated.
598 % The format of the GetCacheViewVirtualPixelQueue() method is:
600 % const Quantum *GetCacheViewVirtualPixelQueue(
601 % const CacheView *cache_view)
603 % A description of each parameter follows:
605 % o cache_view: the cache view.
608 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
609 const CacheView *cache_view)
612 id = GetOpenMPThreadId();
617 assert(cache_view != (const CacheView *) NULL);
618 assert(cache_view->signature == MagickSignature);
619 assert(cache_view->image->cache != (Cache) NULL);
620 assert(id < (int) cache_view->number_threads);
621 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
622 cache_view->nexus_info[id]);
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 % 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 %
635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
638 % disk pixel cache as defined by the geometry parameters. A pointer to the
639 % pixels is returned if the pixels are transferred, otherwise a NULL is
642 % The format of the GetCacheViewVirtualPixels method is:
644 % const Quantum *GetCacheViewVirtualPixels(
645 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
646 % const size_t columns,const size_t rows,ExceptionInfo *exception)
648 % A description of each parameter follows:
650 % o cache_view: the cache view.
652 % o x,y,columns,rows: These values define the perimeter of a region of
655 % o exception: return any errors or warnings in this structure.
658 MagickExport const Quantum *GetCacheViewVirtualPixels(
659 const CacheView *cache_view,const ssize_t x,const ssize_t y,
660 const size_t columns,const size_t rows,ExceptionInfo *exception)
663 id = GetOpenMPThreadId();
668 assert(cache_view != (CacheView *) NULL);
669 assert(cache_view->signature == MagickSignature);
670 assert(id < (int) cache_view->number_threads);
671 pixels=GetVirtualPixelsFromNexus(cache_view->image,
672 cache_view->virtual_pixel_method,x,y,columns,rows,
673 cache_view->nexus_info[id],exception);
678 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
682 % 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 %
686 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
688 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
689 % location. The image background color is returned if an error occurs.
691 % The format of the GetOneCacheViewAuthenticPixel method is:
693 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
694 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
695 % Quantum *pixel,ExceptionInfo *exception)
697 % A description of each parameter follows:
699 % o cache_view: the cache view.
701 % o x,y: These values define the offset of the pixel.
703 % o pixel: return a pixel at the specified (x,y) location.
705 % o exception: return any errors or warnings in this structure.
708 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
709 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
710 ExceptionInfo *exception)
713 id = GetOpenMPThreadId();
721 assert(cache_view != (CacheView *) NULL);
722 assert(cache_view->signature == MagickSignature);
723 assert(id < (int) cache_view->number_threads);
724 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
725 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
726 cache_view->nexus_info[id],exception);
727 if (p == (const Quantum *) NULL)
732 background_color=cache_view->image->background_color;
733 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
734 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
735 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
736 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
737 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
740 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
745 channel=GetPixelChannelMapChannel(cache_view->image,i);
752 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
756 % 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 %
760 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
762 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
763 % location. The image background color is returned if an error occurs. If
764 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
766 % The format of the GetOneCacheViewVirtualPixel method is:
768 % MagickBooleanType GetOneCacheViewVirtualPixel(
769 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
770 % Quantum *pixel,ExceptionInfo *exception)
772 % A description of each parameter follows:
774 % o cache_view: the cache view.
776 % o x,y: These values define the offset of the pixel.
778 % o pixel: return a pixel at the specified (x,y) location.
780 % o exception: return any errors or warnings in this structure.
783 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
784 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
785 ExceptionInfo *exception)
788 id = GetOpenMPThreadId();
790 register const Quantum
796 assert(cache_view != (CacheView *) NULL);
797 assert(cache_view->signature == MagickSignature);
798 assert(id < (int) cache_view->number_threads);
799 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
800 p=GetVirtualPixelsFromNexus(cache_view->image,
801 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
803 if (p == (const Quantum *) NULL)
808 background_color=cache_view->image->background_color;
809 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
810 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
811 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
812 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
813 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
816 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
821 channel=GetPixelChannelMapChannel(cache_view->image,i);
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % 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 %
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
839 % (x,y) location. The image background color is returned if an error occurs.
840 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
842 % The format of the GetOneCacheViewVirtualPixelInfo method is:
844 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
845 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
846 % PixelInfo *pixel,ExceptionInfo *exception)
848 % A description of each parameter follows:
850 % o cache_view: the cache view.
852 % o x,y: These values define the offset of the pixel.
854 % o pixel: return a pixel at the specified (x,y) location.
856 % o exception: return any errors or warnings in this structure.
859 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
860 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
861 ExceptionInfo *exception)
864 id = GetOpenMPThreadId();
866 register const Quantum
869 assert(cache_view != (CacheView *) NULL);
870 assert(cache_view->signature == MagickSignature);
871 assert(id < (int) cache_view->number_threads);
872 GetPixelInfo(cache_view->image,pixel);
873 p=GetVirtualPixelsFromNexus(cache_view->image,
874 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
876 if (p == (const Quantum *) NULL)
878 GetPixelInfoPixel(cache_view->image,p,pixel);
883 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
887 % 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 %
891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
893 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
894 % the specified (x,y) location. The image background color is returned if an
895 % error occurs. If you plan to modify the pixel, use
896 % GetOneCacheViewAuthenticPixel() instead.
898 % The format of the GetOneCacheViewVirtualPixel method is:
900 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
901 % const CacheView *cache_view,
902 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
903 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
905 % A description of each parameter follows:
907 % o cache_view: the cache view.
909 % o virtual_pixel_method: the virtual pixel method.
911 % o x,y: These values define the offset of the pixel.
913 % o pixel: return a pixel at the specified (x,y) location.
915 % o exception: return any errors or warnings in this structure.
918 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
919 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
920 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
923 id = GetOpenMPThreadId();
931 assert(cache_view != (CacheView *) NULL);
932 assert(cache_view->signature == MagickSignature);
933 assert(id < (int) cache_view->number_threads);
934 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
935 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
936 cache_view->nexus_info[id],exception);
937 if (p == (const Quantum *) NULL)
942 background_color=cache_view->image->background_color;
943 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
944 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
945 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
946 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
947 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
950 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
955 channel=GetPixelChannelMapChannel(cache_view->image,i);
962 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
966 % 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 %
970 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
972 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
973 % disk pixel cache as defined by the geometry parameters. A pointer to the
974 % pixels is returned if the pixels are transferred, otherwise a NULL is
977 % The format of the QueueCacheViewAuthenticPixels method is:
979 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
980 % const ssize_t x,const ssize_t y,const size_t columns,
981 % const size_t rows,ExceptionInfo *exception)
983 % A description of each parameter follows:
985 % o cache_view: the cache view.
987 % o x,y,columns,rows: These values define the perimeter of a region of
990 % o exception: return any errors or warnings in this structure.
993 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
994 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
995 ExceptionInfo *exception)
998 id = GetOpenMPThreadId();
1003 assert(cache_view != (CacheView *) NULL);
1004 assert(cache_view->signature == MagickSignature);
1005 assert(id < (int) cache_view->number_threads);
1006 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
1007 MagickFalse,cache_view->nexus_info[id],exception);
1012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1016 % S e t C a c h e V i e w S t o r a g e C l a s s %
1020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1022 % SetCacheViewStorageClass() sets the image storage class associated with
1023 % the specified view.
1025 % The format of the SetCacheViewStorageClass method is:
1027 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1028 % const ClassType storage_class,ExceptionInfo *exception)
1030 % A description of each parameter follows:
1032 % o cache_view: the cache view.
1034 % o storage_class: the image storage class: PseudoClass or DirectClass.
1036 % o exception: return any errors or warnings in this structure.
1039 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1040 const ClassType storage_class,ExceptionInfo *exception)
1042 assert(cache_view != (CacheView *) NULL);
1043 assert(cache_view->signature == MagickSignature);
1044 if (cache_view->debug != MagickFalse)
1045 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1046 cache_view->image->filename);
1047 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1055 % 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 %
1059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1061 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1062 % with the specified cache view.
1064 % The format of the SetCacheViewVirtualPixelMethod method is:
1066 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1067 % const VirtualPixelMethod virtual_pixel_method)
1069 % A description of each parameter follows:
1071 % o cache_view: the cache view.
1073 % o virtual_pixel_method: the virtual pixel method.
1076 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1077 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1079 assert(cache_view != (CacheView *) NULL);
1080 assert(cache_view->signature == MagickSignature);
1081 if (cache_view->debug != MagickFalse)
1082 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1083 cache_view->image->filename);
1084 cache_view->virtual_pixel_method=virtual_pixel_method;
1089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1093 % 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 %
1097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1099 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1100 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1101 % otherwise MagickFalse.
1103 % The format of the SyncCacheViewAuthenticPixels method is:
1105 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1106 % ExceptionInfo *exception)
1108 % A description of each parameter follows:
1110 % o cache_view: the cache view.
1112 % o exception: return any errors or warnings in this structure.
1115 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1116 CacheView *cache_view,ExceptionInfo *exception)
1119 id = GetOpenMPThreadId();
1124 assert(cache_view != (CacheView *) NULL);
1125 assert(cache_view->signature == MagickSignature);
1126 assert(id < (int) cache_view->number_threads);
1127 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1128 cache_view->nexus_info[id],exception);