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-2011 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/string_.h"
58 #include "MagickCore/thread-private.h"
85 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 % A c q u i r e C a c h e V i e w %
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % AcquireCacheView() acquires a view into the pixel cache, using the
96 % VirtualPixelMethod that is defined within the given image itself.
98 % The format of the AcquireCacheView method is:
100 % CacheView *AcquireCacheView(const Image *image)
102 % A description of each parameter follows:
104 % o image: the image.
107 MagickExport CacheView *AcquireCacheView(const Image *image)
112 assert(image != (Image *) NULL);
113 assert(image->signature == MagickSignature);
114 if (image->debug != MagickFalse)
115 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
116 cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
117 if (cache_view == (CacheView *) NULL)
118 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
119 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
120 cache_view->image=ReferenceImage((Image *) image);
121 cache_view->number_threads=GetOpenMPMaximumThreads();
122 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
123 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
124 cache_view->debug=IsEventLogging();
125 cache_view->signature=MagickSignature;
126 if (cache_view->nexus_info == (NexusInfo **) NULL)
127 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 % C l o n e C a c h e V i e w %
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % CloneCacheView() makes an exact copy of the specified cache view.
144 % The format of the CloneCacheView method is:
146 % CacheView *CloneCacheView(const CacheView *cache_view)
148 % A description of each parameter follows:
150 % o cache_view: the cache view.
153 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
158 assert(cache_view != (CacheView *) NULL);
159 assert(cache_view->signature == MagickSignature);
160 if (cache_view->debug != MagickFalse)
161 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
162 cache_view->image->filename);
163 clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
164 if (clone_view == (CacheView *) NULL)
165 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
166 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
167 clone_view->image=ReferenceImage(cache_view->image);
168 clone_view->number_threads=cache_view->number_threads;
169 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
170 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
171 clone_view->debug=cache_view->debug;
172 clone_view->signature=MagickSignature;
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % D e s t r o y C a c h e V i e w %
185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 % DestroyCacheView() destroys the specified view returned by a previous call
188 % to AcquireCacheView().
190 % The format of the DestroyCacheView method is:
192 % CacheView *DestroyCacheView(CacheView *cache_view)
194 % A description of each parameter follows:
196 % o cache_view: the cache view.
199 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
201 assert(cache_view != (CacheView *) NULL);
202 assert(cache_view->signature == MagickSignature);
203 if (cache_view->debug != MagickFalse)
204 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
205 cache_view->image->filename);
206 if (cache_view->nexus_info != (NexusInfo **) NULL)
207 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
208 cache_view->number_threads);
209 cache_view->image=DestroyImage(cache_view->image);
210 cache_view->signature=(~MagickSignature);
211 cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 % G e t C a c h e V i e w C o l o r s p a c e %
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 % GetCacheViewColorspace() returns the image colorspace associated with the
229 % The format of the GetCacheViewColorspace method is:
231 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
233 % A description of each parameter follows:
235 % o cache_view: the cache view.
238 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
240 assert(cache_view != (CacheView *) NULL);
241 assert(cache_view->signature == MagickSignature);
242 if (cache_view->debug != MagickFalse)
243 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
244 cache_view->image->filename);
245 return(GetPixelCacheColorspace(cache_view->image->cache));
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 % G e t C a c h e V i e w E x c e p t i o n %
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % GetCacheViewException() returns the image exception associated with the
262 % The format of the GetCacheViewException method is:
264 % ExceptionInfo GetCacheViewException(const CacheView *cache_view)
266 % A description of each parameter follows:
268 % o cache_view: the cache view.
271 MagickExport ExceptionInfo *GetCacheViewException(const CacheView *cache_view)
273 assert(cache_view != (CacheView *) NULL);
274 assert(cache_view->signature == MagickSignature);
275 if (cache_view->debug != MagickFalse)
276 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
277 cache_view->image->filename);
278 return(&cache_view->image->exception);
282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286 + G e t C a c h e V i e w E x t e n t %
290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
292 % GetCacheViewExtent() returns the extent of the pixels associated with the
293 % last call to QueueCacheViewAuthenticPixels() or
294 % GetCacheViewAuthenticPixels().
296 % The format of the GetCacheViewExtent() method is:
298 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
300 % A description of each parameter follows:
302 % o cache_view: the cache view.
305 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
308 id = GetOpenMPThreadId();
313 assert(cache_view != (CacheView *) NULL);
314 assert(cache_view->signature == MagickSignature);
315 if (cache_view->debug != MagickFalse)
316 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
317 cache_view->image->filename);
318 assert(cache_view->image->cache != (Cache) NULL);
319 assert(id < (int) cache_view->number_threads);
320 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
321 cache_view->nexus_info[id]);
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 % G e t C a c h e V i e w S t o r a g e C l a s s %
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336 % GetCacheViewStorageClass() returns the image storage class associated with
337 % the specified view.
339 % The format of the GetCacheViewStorageClass method is:
341 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
343 % A description of each parameter follows:
345 % o cache_view: the cache view.
348 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
350 assert(cache_view != (CacheView *) NULL);
351 assert(cache_view->signature == MagickSignature);
352 if (cache_view->debug != MagickFalse)
353 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
354 cache_view->image->filename);
355 return(GetPixelCacheStorageClass(cache_view->image->cache));
359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363 % 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 %
367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
369 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
370 % cache as defined by the geometry parameters. A pointer to the pixels is
371 % returned if the pixels are transferred, otherwise a NULL is returned.
373 % The format of the GetCacheViewAuthenticPixels method is:
375 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
376 % const ssize_t x,const ssize_t y,const size_t columns,
377 % const size_t rows,ExceptionInfo *exception)
379 % A description of each parameter follows:
381 % o cache_view: the cache view.
383 % o x,y,columns,rows: These values define the perimeter of a region of
387 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
388 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
389 ExceptionInfo *exception)
392 id = GetOpenMPThreadId();
397 assert(cache_view != (CacheView *) NULL);
398 assert(cache_view->signature == MagickSignature);
399 assert(id < (int) cache_view->number_threads);
400 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
401 cache_view->nexus_info[id],exception);
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410 % 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 %
414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
417 % with the last call to SetCacheViewIndexes() or
418 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
421 % The format of the GetCacheViewAuthenticMetacontent() method is:
423 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
425 % A description of each parameter follows:
427 % o cache_view: the cache view.
430 MagickExport void *GetCacheViewAuthenticMetacontent(
431 CacheView *cache_view)
434 id = GetOpenMPThreadId();
439 assert(cache_view != (CacheView *) NULL);
440 assert(cache_view->signature == MagickSignature);
441 assert(cache_view->image->cache != (Cache) NULL);
442 assert(id < (int) cache_view->number_threads);
443 metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
444 cache_view->nexus_info[id]);
449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
453 % 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 %
457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
459 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
460 % last call to QueueCacheViewAuthenticPixels() or
461 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
464 % The format of the GetCacheViewAuthenticPixelQueue() method is:
466 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
468 % A description of each parameter follows:
470 % o cache_view: the cache view.
473 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
476 id = GetOpenMPThreadId();
481 assert(cache_view != (CacheView *) NULL);
482 assert(cache_view->signature == MagickSignature);
483 assert(cache_view->image->cache != (Cache) NULL);
484 assert(id < (int) cache_view->number_threads);
485 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
486 cache_view->nexus_info[id]);
491 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
495 % 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 %
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
502 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
503 % is virtual and therefore cannot be updated.
505 % The format of the GetCacheViewVirtualMetacontent() method is:
507 % const void *GetCacheViewVirtualMetacontent(
508 % const CacheView *cache_view)
510 % A description of each parameter follows:
512 % o cache_view: the cache view.
515 MagickExport const void *GetCacheViewVirtualMetacontent(
516 const CacheView *cache_view)
519 id = GetOpenMPThreadId();
524 assert(cache_view != (const CacheView *) NULL);
525 assert(cache_view->signature == MagickSignature);
526 assert(cache_view->image->cache != (Cache) NULL);
527 assert(id < (int) cache_view->number_threads);
528 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
529 cache_view->nexus_info[id]);
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538 % 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 %
542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
545 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
546 % and therefore cannot be updated.
548 % The format of the GetCacheViewVirtualPixelQueue() method is:
550 % const Quantum *GetCacheViewVirtualPixelQueue(
551 % const CacheView *cache_view)
553 % A description of each parameter follows:
555 % o cache_view: the cache view.
558 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
559 const CacheView *cache_view)
562 id = GetOpenMPThreadId();
567 assert(cache_view != (const CacheView *) NULL);
568 assert(cache_view->signature == MagickSignature);
569 assert(cache_view->image->cache != (Cache) NULL);
570 assert(id < (int) cache_view->number_threads);
571 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
572 cache_view->nexus_info[id]);
577 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581 % 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 %
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
588 % disk pixel cache as defined by the geometry parameters. A pointer to the
589 % pixels is returned if the pixels are transferred, otherwise a NULL is
592 % The format of the GetCacheViewVirtualPixels method is:
594 % const Quantum *GetCacheViewVirtualPixels(
595 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
596 % const size_t columns,const size_t rows,ExceptionInfo *exception)
598 % A description of each parameter follows:
600 % o cache_view: the cache view.
602 % o x,y,columns,rows: These values define the perimeter of a region of
605 % o exception: return any errors or warnings in this structure.
608 MagickExport const Quantum *GetCacheViewVirtualPixels(
609 const CacheView *cache_view,const ssize_t x,const ssize_t y,
610 const size_t columns,const size_t rows,ExceptionInfo *exception)
613 id = GetOpenMPThreadId();
618 assert(cache_view != (CacheView *) NULL);
619 assert(cache_view->signature == MagickSignature);
620 assert(id < (int) cache_view->number_threads);
621 pixels=GetVirtualPixelsFromNexus(cache_view->image,
622 cache_view->virtual_pixel_method,x,y,columns,rows,
623 cache_view->nexus_info[id],exception);
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
632 % 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 %
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
639 % location. The image background color is returned if an error occurs.
641 % The format of the GetOneCacheViewAuthenticPixel method is:
643 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
644 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
645 % Quantum *pixel,ExceptionInfo *exception)
647 % A description of each parameter follows:
649 % o cache_view: the cache view.
651 % o x,y: These values define the offset of the pixel.
653 % o pixel: return a pixel at the specified (x,y) location.
655 % o exception: return any errors or warnings in this structure.
658 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
659 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
660 ExceptionInfo *exception)
663 id = GetOpenMPThreadId();
671 assert(cache_view != (CacheView *) NULL);
672 assert(cache_view->signature == MagickSignature);
673 assert(id < (int) cache_view->number_threads);
674 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
675 p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
676 cache_view->nexus_info[id],exception);
677 if (p == (const Quantum *) NULL)
679 pixel[RedPixelChannel]=cache_view->image->background_color.red;
680 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
681 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
682 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
685 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
690 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701 % 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 %
705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
707 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
708 % location. The image background color is returned if an error occurs. If
709 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
711 % The format of the GetOneCacheViewVirtualPixel method is:
713 % MagickBooleanType GetOneCacheViewVirtualPixel(
714 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
715 % Quantum *pixel,ExceptionInfo *exception)
717 % A description of each parameter follows:
719 % o cache_view: the cache view.
721 % o x,y: These values define the offset of the pixel.
723 % o pixel: return a pixel at the specified (x,y) location.
725 % o exception: return any errors or warnings in this structure.
728 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
729 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
730 ExceptionInfo *exception)
733 id = GetOpenMPThreadId();
741 assert(cache_view != (CacheView *) NULL);
742 assert(cache_view->signature == MagickSignature);
743 assert(id < (int) cache_view->number_threads);
744 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
745 p=GetVirtualPixelsFromNexus(cache_view->image,
746 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
748 if (p == (const Quantum *) NULL)
750 pixel[RedPixelChannel]=cache_view->image->background_color.red;
751 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
752 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
753 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
756 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
761 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
768 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
772 % 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 %
776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
779 % the specified (x,y) location. The image background color is returned if an
780 % error occurs. If you plan to modify the pixel, use
781 % GetOneCacheViewAuthenticPixel() instead.
783 % The format of the GetOneCacheViewVirtualPixel method is:
785 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
786 % const CacheView *cache_view,
787 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
788 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
790 % A description of each parameter follows:
792 % o cache_view: the cache view.
794 % o virtual_pixel_method: the virtual pixel method.
796 % o x,y: These values define the offset of the pixel.
798 % o pixel: return a pixel at the specified (x,y) location.
800 % o exception: return any errors or warnings in this structure.
803 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
804 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
805 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
808 id = GetOpenMPThreadId();
816 assert(cache_view != (CacheView *) NULL);
817 assert(cache_view->signature == MagickSignature);
818 assert(id < (int) cache_view->number_threads);
819 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
820 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
821 cache_view->nexus_info[id],exception);
822 if (p == (const Quantum *) NULL)
824 pixel[RedPixelChannel]=cache_view->image->background_color.red;
825 pixel[GreenPixelChannel]=cache_view->image->background_color.green;
826 pixel[BluePixelChannel]=cache_view->image->background_color.blue;
827 pixel[AlphaPixelChannel]=cache_view->image->background_color.alpha;
830 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
835 channel=GetPixelChannelMapChannel(cache_view->image,(PixelChannel) i);
842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
846 % 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 %
850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
853 % disk pixel cache as defined by the geometry parameters. A pointer to the
854 % pixels is returned if the pixels are transferred, otherwise a NULL is
857 % The format of the QueueCacheViewAuthenticPixels method is:
859 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
860 % const ssize_t x,const ssize_t y,const size_t columns,
861 % const size_t rows,ExceptionInfo *exception)
863 % A description of each parameter follows:
865 % o cache_view: the cache view.
867 % o x,y,columns,rows: These values define the perimeter of a region of
870 % o exception: return any errors or warnings in this structure.
873 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
874 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
875 ExceptionInfo *exception)
878 id = GetOpenMPThreadId();
883 assert(cache_view != (CacheView *) NULL);
884 assert(cache_view->signature == MagickSignature);
885 assert(id < (int) cache_view->number_threads);
886 pixels=QueueAuthenticNexus(cache_view->image,x,y,columns,rows,
887 cache_view->nexus_info[id],exception);
892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
896 % S e t C a c h e V i e w S t o r a g e C l a s s %
900 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902 % SetCacheViewStorageClass() sets the image storage class associated with
903 % the specified view.
905 % The format of the SetCacheViewStorageClass method is:
907 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
908 % const ClassType storage_class)
910 % A description of each parameter follows:
912 % o cache_view: the cache view.
914 % o storage_class: the image storage class: PseudoClass or DirectClass.
917 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
918 const ClassType storage_class)
923 assert(cache_view != (CacheView *) NULL);
924 assert(cache_view->signature == MagickSignature);
925 if (cache_view->debug != MagickFalse)
926 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
927 cache_view->image->filename);
928 status=SetImageStorageClass(cache_view->image,storage_class,
929 &cache_view->image->exception);
934 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938 % 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 %
942 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
944 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
945 % with the specified cache view.
947 % The format of the SetCacheViewVirtualPixelMethod method is:
949 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
950 % const VirtualPixelMethod virtual_pixel_method)
952 % A description of each parameter follows:
954 % o cache_view: the cache view.
956 % o virtual_pixel_method: the virtual pixel method.
959 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
960 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
962 assert(cache_view != (CacheView *) NULL);
963 assert(cache_view->signature == MagickSignature);
964 if (cache_view->debug != MagickFalse)
965 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
966 cache_view->image->filename);
967 cache_view->virtual_pixel_method=virtual_pixel_method;
972 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976 % 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 %
980 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
982 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
983 % or disk cache. It returns MagickTrue if the pixel region is flushed,
984 % otherwise MagickFalse.
986 % The format of the SyncCacheViewAuthenticPixels method is:
988 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
989 % ExceptionInfo *exception)
991 % A description of each parameter follows:
993 % o cache_view: the cache view.
995 % o exception: return any errors or warnings in this structure.
998 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
999 CacheView *cache_view,ExceptionInfo *exception)
1002 id = GetOpenMPThreadId();
1007 assert(cache_view != (CacheView *) NULL);
1008 assert(cache_view->signature == MagickSignature);
1009 assert(id < (int) cache_view->number_threads);
1010 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1011 cache_view->nexus_info[id],exception);