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/exception.h"
55 #include "MagickCore/exception-private.h"
56 #include "MagickCore/pixel-accessor.h"
57 #include "MagickCore/resource_.h"
58 #include "MagickCore/string_.h"
59 #include "MagickCore/thread-private.h"
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 % 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 %
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96 % AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
98 % The format of the AcquireAuthenticCacheView method is:
100 % CacheView *AcquireAuthenticCacheView(const Image *image,
101 % ExceptionInfo *exception)
103 % A description of each parameter follows:
105 % o image: the image.
107 % o exception: return any errors or warnings in this structure.
110 MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
111 ExceptionInfo *exception)
119 cache_view=AcquireVirtualCacheView(image,exception);
120 status=SyncImagePixelCache(cache_view->image,exception);
121 if (status == MagickFalse)
122 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 % A c q u i r e V i r t u a l C a c h e V i e w %
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
138 % using the VirtualPixelMethod that is defined within the given image itself.
140 % The format of the AcquireVirtualCacheView method is:
142 % CacheView *AcquireVirtualCacheView(const Image *image,
143 % ExceptionInfo *exception)
145 % A description of each parameter follows:
147 % o image: the image.
149 % o exception: return any errors or warnings in this structure.
152 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
153 ExceptionInfo *exception)
158 assert(image != (Image *) NULL);
159 assert(image->signature == MagickSignature);
160 if (image->debug != MagickFalse)
161 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
163 cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
164 if (cache_view == (CacheView *) NULL)
165 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
166 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
167 cache_view->image=ReferenceImage((Image *) image);
168 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
169 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
170 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
171 cache_view->debug=IsEventLogging();
172 cache_view->signature=MagickSignature;
173 if (cache_view->nexus_info == (NexusInfo **) NULL)
174 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 % C l o n e C a c h e V i e w %
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189 % CloneCacheView() makes an exact copy of the specified cache view.
191 % The format of the CloneCacheView method is:
193 % CacheView *CloneCacheView(const CacheView *cache_view)
195 % A description of each parameter follows:
197 % o cache_view: the cache view.
200 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
205 assert(cache_view != (CacheView *) NULL);
206 assert(cache_view->signature == MagickSignature);
207 if (cache_view->debug != MagickFalse)
208 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
209 cache_view->image->filename);
210 clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
211 if (clone_view == (CacheView *) NULL)
212 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
213 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
214 clone_view->image=ReferenceImage(cache_view->image);
215 clone_view->number_threads=cache_view->number_threads;
216 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
217 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
218 clone_view->debug=cache_view->debug;
219 clone_view->signature=MagickSignature;
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 % D e s t r o y C a c h e V i e w %
232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 % DestroyCacheView() destroys the specified view returned by a previous call
235 % to AcquireCacheView().
237 % The format of the DestroyCacheView method is:
239 % CacheView *DestroyCacheView(CacheView *cache_view)
241 % A description of each parameter follows:
243 % o cache_view: the cache view.
246 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
248 assert(cache_view != (CacheView *) NULL);
249 assert(cache_view->signature == MagickSignature);
250 if (cache_view->debug != MagickFalse)
251 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
252 cache_view->image->filename);
253 if (cache_view->nexus_info != (NexusInfo **) NULL)
254 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
255 cache_view->number_threads);
256 cache_view->image=DestroyImage(cache_view->image);
257 cache_view->signature=(~MagickSignature);
258 cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267 % 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 %
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
274 % cache as defined by the geometry parameters. A pointer to the pixels is
275 % returned if the pixels are transferred, otherwise a NULL is returned.
277 % The format of the GetCacheViewAuthenticPixels method is:
279 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
280 % const ssize_t x,const ssize_t y,const size_t columns,
281 % const size_t rows,ExceptionInfo *exception)
283 % A description of each parameter follows:
285 % o cache_view: the cache view.
287 % o x,y,columns,rows: These values define the perimeter of a region of
290 % o exception: return any errors or warnings in this structure.
293 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
294 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
295 ExceptionInfo *exception)
298 id = GetOpenMPThreadId();
303 assert(cache_view != (CacheView *) NULL);
304 assert(cache_view->signature == MagickSignature);
305 assert(id < (int) cache_view->number_threads);
306 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
307 cache_view->nexus_info[id],exception);
312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 % 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 %
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
323 % with the last call to SetCacheViewIndexes() or
324 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
327 % The format of the GetCacheViewAuthenticMetacontent() method is:
329 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
331 % A description of each parameter follows:
333 % o cache_view: the cache view.
336 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
339 id = GetOpenMPThreadId();
344 assert(cache_view != (CacheView *) NULL);
345 assert(cache_view->signature == MagickSignature);
346 assert(cache_view->image->cache != (Cache) NULL);
347 assert(id < (int) cache_view->number_threads);
348 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
349 cache_view->nexus_info[id]);
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
358 % 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 %
362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
365 % last call to QueueCacheViewAuthenticPixels() or
366 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
369 % The format of the GetCacheViewAuthenticPixelQueue() method is:
371 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
373 % A description of each parameter follows:
375 % o cache_view: the cache view.
378 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
381 id = GetOpenMPThreadId();
386 assert(cache_view != (CacheView *) NULL);
387 assert(cache_view->signature == MagickSignature);
388 assert(cache_view->image->cache != (Cache) NULL);
389 assert(id < (int) cache_view->number_threads);
390 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
391 cache_view->nexus_info[id]);
396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 % G e t C a c h e V i e w C o l o r s p a c e %
404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
406 % GetCacheViewColorspace() returns the image colorspace associated with the
409 % The format of the GetCacheViewColorspace method is:
411 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
413 % A description of each parameter follows:
415 % o cache_view: the cache view.
418 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
420 assert(cache_view != (CacheView *) NULL);
421 assert(cache_view->signature == MagickSignature);
422 if (cache_view->debug != MagickFalse)
423 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
424 cache_view->image->filename);
425 return(GetPixelCacheColorspace(cache_view->image->cache));
429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433 + G e t C a c h e V i e w E x t e n t %
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439 % GetCacheViewExtent() returns the extent of the pixels associated with the
440 % last call to QueueCacheViewAuthenticPixels() or
441 % GetCacheViewAuthenticPixels().
443 % The format of the GetCacheViewExtent() method is:
445 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
447 % A description of each parameter follows:
449 % o cache_view: the cache view.
452 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
455 id = GetOpenMPThreadId();
460 assert(cache_view != (CacheView *) NULL);
461 assert(cache_view->signature == MagickSignature);
462 if (cache_view->debug != MagickFalse)
463 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
464 cache_view->image->filename);
465 assert(cache_view->image->cache != (Cache) NULL);
466 assert(id < (int) cache_view->number_threads);
467 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
468 cache_view->nexus_info[id]);
473 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477 % G e t C a c h e V i e w I m a g e %
481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 % GetCacheViewImage() returns the image associated with the specified view.
485 % The format of the GetCacheViewImage method is:
487 % const Image *GetCacheViewImage(const CacheView *cache_view)
489 % A description of each parameter follows:
491 % o cache_view: the cache view.
494 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
496 assert(cache_view != (CacheView *) NULL);
497 assert(cache_view->signature == MagickSignature);
498 if (cache_view->debug != MagickFalse)
499 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
500 cache_view->image->filename);
501 return(cache_view->image);
505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 % G e t C a c h e V i e w S t o r a g e C l a s s %
513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
515 % GetCacheViewStorageClass() returns the image storage class associated with
516 % the specified view.
518 % The format of the GetCacheViewStorageClass method is:
520 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
522 % A description of each parameter follows:
524 % o cache_view: the cache view.
527 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
529 assert(cache_view != (CacheView *) NULL);
530 assert(cache_view->signature == MagickSignature);
531 if (cache_view->debug != MagickFalse)
532 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
533 cache_view->image->filename);
534 return(GetPixelCacheStorageClass(cache_view->image->cache));
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 % 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 %
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
549 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
550 % is virtual and therefore cannot be updated.
552 % The format of the GetCacheViewVirtualMetacontent() method is:
554 % const void *GetCacheViewVirtualMetacontent(
555 % const CacheView *cache_view)
557 % A description of each parameter follows:
559 % o cache_view: the cache view.
562 MagickExport const void *GetCacheViewVirtualMetacontent(
563 const CacheView *cache_view)
566 id = GetOpenMPThreadId();
571 assert(cache_view != (const CacheView *) NULL);
572 assert(cache_view->signature == MagickSignature);
573 assert(cache_view->image->cache != (Cache) NULL);
574 assert(id < (int) cache_view->number_threads);
575 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
576 cache_view->nexus_info[id]);
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % 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 %
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
592 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
593 % and therefore cannot be updated.
595 % The format of the GetCacheViewVirtualPixelQueue() method is:
597 % const Quantum *GetCacheViewVirtualPixelQueue(
598 % const CacheView *cache_view)
600 % A description of each parameter follows:
602 % o cache_view: the cache view.
605 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
606 const CacheView *cache_view)
609 id = GetOpenMPThreadId();
614 assert(cache_view != (const CacheView *) NULL);
615 assert(cache_view->signature == MagickSignature);
616 assert(cache_view->image->cache != (Cache) NULL);
617 assert(id < (int) cache_view->number_threads);
618 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
619 cache_view->nexus_info[id]);
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 % 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 %
632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
634 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
635 % disk pixel cache as defined by the geometry parameters. A pointer to the
636 % pixels is returned if the pixels are transferred, otherwise a NULL is
639 % The format of the GetCacheViewVirtualPixels method is:
641 % const Quantum *GetCacheViewVirtualPixels(
642 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
643 % const size_t columns,const size_t rows,ExceptionInfo *exception)
645 % A description of each parameter follows:
647 % o cache_view: the cache view.
649 % o x,y,columns,rows: These values define the perimeter of a region of
652 % o exception: return any errors or warnings in this structure.
655 MagickExport const Quantum *GetCacheViewVirtualPixels(
656 const CacheView *cache_view,const ssize_t x,const ssize_t y,
657 const size_t columns,const size_t rows,ExceptionInfo *exception)
660 id = GetOpenMPThreadId();
665 assert(cache_view != (CacheView *) NULL);
666 assert(cache_view->signature == MagickSignature);
667 assert(id < (int) cache_view->number_threads);
668 pixels=GetVirtualPixelsFromNexus(cache_view->image,
669 cache_view->virtual_pixel_method,x,y,columns,rows,
670 cache_view->nexus_info[id],exception);
675 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
679 % 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 %
683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
685 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
686 % location. The image background color is returned if an error occurs.
688 % The format of the GetOneCacheViewAuthenticPixel method is:
690 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
691 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
692 % Quantum *pixel,ExceptionInfo *exception)
694 % A description of each parameter follows:
696 % o cache_view: the cache view.
698 % o x,y: These values define the offset of the pixel.
700 % o pixel: return a pixel at the specified (x,y) location.
702 % o exception: return any errors or warnings in this structure.
705 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
706 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
707 ExceptionInfo *exception)
710 id = GetOpenMPThreadId();
718 assert(cache_view != (CacheView *) NULL);
719 assert(cache_view->signature == MagickSignature);
720 assert(id < (int) cache_view->number_threads);
721 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
722 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
723 cache_view->nexus_info[id],exception);
724 if (p == (const Quantum *) NULL)
729 background_color=cache_view->image->background_color;
730 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
731 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
732 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
733 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
734 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
737 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
742 channel=GetPixelChannelMapChannel(cache_view->image,i);
749 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
753 % 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 %
757 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
759 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
760 % location. The image background color is returned if an error occurs. If
761 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
763 % The format of the GetOneCacheViewVirtualPixel method is:
765 % MagickBooleanType GetOneCacheViewVirtualPixel(
766 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
767 % Quantum *pixel,ExceptionInfo *exception)
769 % A description of each parameter follows:
771 % o cache_view: the cache view.
773 % o x,y: These values define the offset of the pixel.
775 % o pixel: return a pixel at the specified (x,y) location.
777 % o exception: return any errors or warnings in this structure.
780 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
781 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
782 ExceptionInfo *exception)
785 id = GetOpenMPThreadId();
787 register const Quantum
793 assert(cache_view != (CacheView *) NULL);
794 assert(cache_view->signature == MagickSignature);
795 assert(id < (int) cache_view->number_threads);
796 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
797 p=GetVirtualPixelsFromNexus(cache_view->image,
798 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
800 if (p == (const Quantum *) NULL)
805 background_color=cache_view->image->background_color;
806 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
807 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
808 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
809 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
810 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
813 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
818 channel=GetPixelChannelMapChannel(cache_view->image,i);
825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 % 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 %
833 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
836 % (x,y) location. The image background color is returned if an error occurs.
837 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
839 % The format of the GetOneCacheViewVirtualPixelInfo method is:
841 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
842 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
843 % PixelInfo *pixel,ExceptionInfo *exception)
845 % A description of each parameter follows:
847 % o cache_view: the cache view.
849 % o x,y: These values define the offset of the pixel.
851 % o pixel: return a pixel at the specified (x,y) location.
853 % o exception: return any errors or warnings in this structure.
856 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
857 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
858 ExceptionInfo *exception)
861 id = GetOpenMPThreadId();
863 register const Quantum
866 assert(cache_view != (CacheView *) NULL);
867 assert(cache_view->signature == MagickSignature);
868 assert(id < (int) cache_view->number_threads);
869 GetPixelInfo(cache_view->image,pixel);
870 p=GetVirtualPixelsFromNexus(cache_view->image,
871 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
873 if (p == (const Quantum *) NULL)
875 GetPixelInfoPixel(cache_view->image,p,pixel);
880 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 % 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 %
888 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
891 % the specified (x,y) location. The image background color is returned if an
892 % error occurs. If you plan to modify the pixel, use
893 % GetOneCacheViewAuthenticPixel() instead.
895 % The format of the GetOneCacheViewVirtualPixel method is:
897 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
898 % const CacheView *cache_view,
899 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
900 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
902 % A description of each parameter follows:
904 % o cache_view: the cache view.
906 % o virtual_pixel_method: the virtual pixel method.
908 % o x,y: These values define the offset of the pixel.
910 % o pixel: return a pixel at the specified (x,y) location.
912 % o exception: return any errors or warnings in this structure.
915 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
916 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
917 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
920 id = GetOpenMPThreadId();
928 assert(cache_view != (CacheView *) NULL);
929 assert(cache_view->signature == MagickSignature);
930 assert(id < (int) cache_view->number_threads);
931 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
932 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
933 cache_view->nexus_info[id],exception);
934 if (p == (const Quantum *) NULL)
939 background_color=cache_view->image->background_color;
940 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
941 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
942 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
943 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
944 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
947 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
952 channel=GetPixelChannelMapChannel(cache_view->image,i);
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
963 % 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 %
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
970 % disk pixel cache as defined by the geometry parameters. A pointer to the
971 % pixels is returned if the pixels are transferred, otherwise a NULL is
974 % The format of the QueueCacheViewAuthenticPixels method is:
976 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
977 % const ssize_t x,const ssize_t y,const size_t columns,
978 % const size_t rows,ExceptionInfo *exception)
980 % A description of each parameter follows:
982 % o cache_view: the cache view.
984 % o x,y,columns,rows: These values define the perimeter of a region of
987 % o exception: return any errors or warnings in this structure.
990 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
991 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
992 ExceptionInfo *exception)
995 id = GetOpenMPThreadId();
1000 assert(cache_view != (CacheView *) NULL);
1001 assert(cache_view->signature == MagickSignature);
1002 assert(id < (int) cache_view->number_threads);
1003 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
1004 MagickFalse,cache_view->nexus_info[id],exception);
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 % S e t C a c h e V i e w S t o r a g e C l a s s %
1017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1019 % SetCacheViewStorageClass() sets the image storage class associated with
1020 % the specified view.
1022 % The format of the SetCacheViewStorageClass method is:
1024 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1025 % const ClassType storage_class,ExceptionInfo *exception)
1027 % A description of each parameter follows:
1029 % o cache_view: the cache view.
1031 % o storage_class: the image storage class: PseudoClass or DirectClass.
1033 % o exception: return any errors or warnings in this structure.
1036 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1037 const ClassType storage_class,ExceptionInfo *exception)
1039 assert(cache_view != (CacheView *) NULL);
1040 assert(cache_view->signature == MagickSignature);
1041 if (cache_view->debug != MagickFalse)
1042 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1043 cache_view->image->filename);
1044 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1052 % 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 %
1056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1058 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1059 % with the specified cache view.
1061 % The format of the SetCacheViewVirtualPixelMethod method is:
1063 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1064 % const VirtualPixelMethod virtual_pixel_method)
1066 % A description of each parameter follows:
1068 % o cache_view: the cache view.
1070 % o virtual_pixel_method: the virtual pixel method.
1073 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1074 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
1076 assert(cache_view != (CacheView *) NULL);
1077 assert(cache_view->signature == MagickSignature);
1078 if (cache_view->debug != MagickFalse)
1079 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1080 cache_view->image->filename);
1081 cache_view->virtual_pixel_method=virtual_pixel_method;
1086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1090 % 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 %
1094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1096 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1097 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1098 % otherwise MagickFalse.
1100 % The format of the SyncCacheViewAuthenticPixels method is:
1102 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1103 % ExceptionInfo *exception)
1105 % A description of each parameter follows:
1107 % o cache_view: the cache view.
1109 % o exception: return any errors or warnings in this structure.
1112 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1113 CacheView *cache_view,ExceptionInfo *exception)
1116 id = GetOpenMPThreadId();
1121 assert(cache_view != (CacheView *) NULL);
1122 assert(cache_view->signature == MagickSignature);
1123 assert(id < (int) cache_view->number_threads);
1124 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1125 cache_view->nexus_info[id],exception);