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-2014 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)
116 *restrict cache_view;
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)
154 *restrict cache_view;
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)
206 *restrict clone_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();
345 assert(cache_view != (CacheView *) NULL);
346 assert(cache_view->signature == MagickSignature);
347 assert(cache_view->image->cache != (Cache) NULL);
348 assert(id < (int) cache_view->number_threads);
349 return(cache_view->nexus_info[id]->metacontent);
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357 % 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 %
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
364 % last call to QueueCacheViewAuthenticPixels() or
365 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
368 % The format of the GetCacheViewAuthenticPixelQueue() method is:
370 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
372 % A description of each parameter follows:
374 % o cache_view: the cache view.
377 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
380 id = GetOpenMPThreadId();
382 assert(cache_view != (CacheView *) NULL);
383 assert(cache_view->signature == MagickSignature);
384 assert(cache_view->image->cache != (Cache) NULL);
385 assert(id < (int) cache_view->number_threads);
386 return(cache_view->nexus_info[id]->pixels);
390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394 % G e t C a c h e V i e w C o l o r s p a c e %
398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400 % GetCacheViewColorspace() returns the image colorspace associated with the
403 % The format of the GetCacheViewColorspace method is:
405 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
407 % A description of each parameter follows:
409 % o cache_view: the cache view.
412 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
414 assert(cache_view != (CacheView *) NULL);
415 assert(cache_view->signature == MagickSignature);
416 if (cache_view->debug != MagickFalse)
417 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
418 cache_view->image->filename);
419 return(GetPixelCacheColorspace(cache_view->image->cache));
423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427 + G e t C a c h e V i e w E x t e n t %
431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
433 % GetCacheViewExtent() returns the extent of the pixels associated with the
434 % last call to QueueCacheViewAuthenticPixels() or
435 % GetCacheViewAuthenticPixels().
437 % The format of the GetCacheViewExtent() method is:
439 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
441 % A description of each parameter follows:
443 % o cache_view: the cache view.
446 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
449 id = GetOpenMPThreadId();
454 assert(cache_view != (CacheView *) NULL);
455 assert(cache_view->signature == MagickSignature);
456 if (cache_view->debug != MagickFalse)
457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
458 cache_view->image->filename);
459 assert(cache_view->image->cache != (Cache) NULL);
460 assert(id < (int) cache_view->number_threads);
461 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
462 cache_view->nexus_info[id]);
467 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471 % G e t C a c h e V i e w I m a g e %
475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477 % GetCacheViewImage() returns the image associated with the specified view.
479 % The format of the GetCacheViewImage method is:
481 % const Image *GetCacheViewImage(const CacheView *cache_view)
483 % A description of each parameter follows:
485 % o cache_view: the cache view.
488 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
490 assert(cache_view != (CacheView *) NULL);
491 assert(cache_view->signature == MagickSignature);
492 if (cache_view->debug != MagickFalse)
493 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
494 cache_view->image->filename);
495 return(cache_view->image);
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 % G e t C a c h e V i e w S t o r a g e C l a s s %
507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 % GetCacheViewStorageClass() returns the image storage class associated with
510 % the specified view.
512 % The format of the GetCacheViewStorageClass method is:
514 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
516 % A description of each parameter follows:
518 % o cache_view: the cache view.
521 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
523 assert(cache_view != (CacheView *) NULL);
524 assert(cache_view->signature == MagickSignature);
525 if (cache_view->debug != MagickFalse)
526 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
527 cache_view->image->filename);
528 return(GetPixelCacheStorageClass(cache_view->image->cache));
532 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536 % 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 %
540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
543 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
544 % is virtual and therefore cannot be updated.
546 % The format of the GetCacheViewVirtualMetacontent() method is:
548 % const void *GetCacheViewVirtualMetacontent(
549 % const CacheView *cache_view)
551 % A description of each parameter follows:
553 % o cache_view: the cache view.
556 MagickExport const void *GetCacheViewVirtualMetacontent(
557 const CacheView *cache_view)
560 id = GetOpenMPThreadId();
563 *restrict metacontent;
565 assert(cache_view != (const CacheView *) NULL);
566 assert(cache_view->signature == MagickSignature);
567 assert(cache_view->image->cache != (Cache) NULL);
568 assert(id < (int) cache_view->number_threads);
569 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
570 cache_view->nexus_info[id]);
575 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579 % 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 %
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
586 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
587 % and therefore cannot be updated.
589 % The format of the GetCacheViewVirtualPixelQueue() method is:
591 % const Quantum *GetCacheViewVirtualPixelQueue(
592 % const CacheView *cache_view)
594 % A description of each parameter follows:
596 % o cache_view: the cache view.
599 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
600 const CacheView *cache_view)
603 id = GetOpenMPThreadId();
608 assert(cache_view != (const CacheView *) NULL);
609 assert(cache_view->signature == MagickSignature);
610 assert(cache_view->image->cache != (Cache) NULL);
611 assert(id < (int) cache_view->number_threads);
612 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
613 cache_view->nexus_info[id]);
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622 % 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 %
626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
629 % disk pixel cache as defined by the geometry parameters. A pointer to the
630 % pixels is returned if the pixels are transferred, otherwise a NULL is
633 % The format of the GetCacheViewVirtualPixels method is:
635 % const Quantum *GetCacheViewVirtualPixels(
636 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
637 % const size_t columns,const size_t rows,ExceptionInfo *exception)
639 % A description of each parameter follows:
641 % o cache_view: the cache view.
643 % o x,y,columns,rows: These values define the perimeter of a region of
646 % o exception: return any errors or warnings in this structure.
649 MagickExport const Quantum *GetCacheViewVirtualPixels(
650 const CacheView *cache_view,const ssize_t x,const ssize_t y,
651 const size_t columns,const size_t rows,ExceptionInfo *exception)
654 id = GetOpenMPThreadId();
659 assert(cache_view != (CacheView *) NULL);
660 assert(cache_view->signature == MagickSignature);
661 assert(id < (int) cache_view->number_threads);
662 pixels=GetVirtualPixelsFromNexus(cache_view->image,
663 cache_view->virtual_pixel_method,x,y,columns,rows,
664 cache_view->nexus_info[id],exception);
669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673 % 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 %
677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
679 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
680 % location. The image background color is returned if an error occurs.
682 % The format of the GetOneCacheViewAuthenticPixel method is:
684 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
685 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
686 % Quantum *pixel,ExceptionInfo *exception)
688 % A description of each parameter follows:
690 % o cache_view: the cache view.
692 % o x,y: These values define the offset of the pixel.
694 % o pixel: return a pixel at the specified (x,y) location.
696 % o exception: return any errors or warnings in this structure.
699 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
700 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
701 ExceptionInfo *exception)
704 id = GetOpenMPThreadId();
712 assert(cache_view != (CacheView *) NULL);
713 assert(cache_view->signature == MagickSignature);
714 assert(id < (int) cache_view->number_threads);
715 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
716 q=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
717 cache_view->nexus_info[id],exception);
718 if (q == (const Quantum *) NULL)
723 background_color=cache_view->image->background_color;
724 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
725 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
726 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
727 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
728 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
731 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
733 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
744 % 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 %
748 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
750 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
751 % location. The image background color is returned if an error occurs. If
752 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
754 % The format of the GetOneCacheViewVirtualPixel method is:
756 % MagickBooleanType GetOneCacheViewVirtualPixel(
757 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
758 % Quantum *pixel,ExceptionInfo *exception)
760 % A description of each parameter follows:
762 % o cache_view: the cache view.
764 % o x,y: These values define the offset of the pixel.
766 % o pixel: return a pixel at the specified (x,y) location.
768 % o exception: return any errors or warnings in this structure.
771 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
772 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
773 ExceptionInfo *exception)
776 id = GetOpenMPThreadId();
778 register const Quantum
784 assert(cache_view != (CacheView *) NULL);
785 assert(cache_view->signature == MagickSignature);
786 assert(id < (int) cache_view->number_threads);
787 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
788 p=GetVirtualPixelsFromNexus(cache_view->image,
789 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
791 if (p == (const Quantum *) NULL)
796 background_color=cache_view->image->background_color;
797 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
798 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
799 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
800 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
801 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
804 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
806 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
817 % 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 %
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
823 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
824 % (x,y) location. The image background color is returned if an error occurs.
825 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
827 % The format of the GetOneCacheViewVirtualPixelInfo method is:
829 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
830 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
831 % PixelInfo *pixel,ExceptionInfo *exception)
833 % A description of each parameter follows:
835 % o cache_view: the cache view.
837 % o x,y: These values define the offset of the pixel.
839 % o pixel: return a pixel at the specified (x,y) location.
841 % o exception: return any errors or warnings in this structure.
844 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
845 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
846 ExceptionInfo *exception)
849 id = GetOpenMPThreadId();
851 register const Quantum
854 assert(cache_view != (CacheView *) NULL);
855 assert(cache_view->signature == MagickSignature);
856 assert(id < (int) cache_view->number_threads);
857 GetPixelInfo(cache_view->image,pixel);
858 p=GetVirtualPixelsFromNexus(cache_view->image,
859 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
861 if (p == (const Quantum *) NULL)
863 GetPixelInfoPixel(cache_view->image,p,pixel);
868 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
872 % 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 %
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
878 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
879 % the specified (x,y) location. The image background color is returned if an
880 % error occurs. If you plan to modify the pixel, use
881 % GetOneCacheViewAuthenticPixel() instead.
883 % The format of the GetOneCacheViewVirtualPixel method is:
885 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
886 % const CacheView *cache_view,
887 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
888 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
890 % A description of each parameter follows:
892 % o cache_view: the cache view.
894 % o virtual_pixel_method: the virtual pixel method.
896 % o x,y: These values define the offset of the pixel.
898 % o pixel: return a pixel at the specified (x,y) location.
900 % o exception: return any errors or warnings in this structure.
903 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
904 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
905 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
908 id = GetOpenMPThreadId();
916 assert(cache_view != (CacheView *) NULL);
917 assert(cache_view->signature == MagickSignature);
918 assert(id < (int) cache_view->number_threads);
919 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
920 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
921 cache_view->nexus_info[id],exception);
922 if (p == (const Quantum *) NULL)
927 background_color=cache_view->image->background_color;
928 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
929 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
930 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
931 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
932 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
935 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
937 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 % 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 %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
955 % disk pixel cache as defined by the geometry parameters. A pointer to the
956 % pixels is returned if the pixels are transferred, otherwise a NULL is
959 % The format of the QueueCacheViewAuthenticPixels method is:
961 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
962 % const ssize_t x,const ssize_t y,const size_t columns,
963 % const size_t rows,ExceptionInfo *exception)
965 % A description of each parameter follows:
967 % o cache_view: the cache view.
969 % o x,y,columns,rows: These values define the perimeter of a region of
972 % o exception: return any errors or warnings in this structure.
975 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
976 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
977 ExceptionInfo *exception)
980 id = GetOpenMPThreadId();
985 assert(cache_view != (CacheView *) NULL);
986 assert(cache_view->signature == MagickSignature);
987 assert(id < (int) cache_view->number_threads);
988 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
989 MagickFalse,cache_view->nexus_info[id],exception);
994 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998 % S e t C a c h e V i e w S t o r a g e C l a s s %
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 % SetCacheViewStorageClass() sets the image storage class associated with
1005 % the specified view.
1007 % The format of the SetCacheViewStorageClass method is:
1009 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1010 % const ClassType storage_class,ExceptionInfo *exception)
1012 % A description of each parameter follows:
1014 % o cache_view: the cache view.
1016 % o storage_class: the image storage class: PseudoClass or DirectClass.
1018 % o exception: return any errors or warnings in this structure.
1021 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1022 const ClassType storage_class,ExceptionInfo *exception)
1024 assert(cache_view != (CacheView *) NULL);
1025 assert(cache_view->signature == MagickSignature);
1026 if (cache_view->debug != MagickFalse)
1027 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1028 cache_view->image->filename);
1029 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1037 % 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 %
1041 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1043 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1044 % with the specified cache view.
1046 % The format of the SetCacheViewVirtualPixelMethod method is:
1048 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1049 % const VirtualPixelMethod virtual_pixel_method)
1051 % A description of each parameter follows:
1053 % o cache_view: the cache view.
1055 % o virtual_pixel_method: the virtual pixel method.
1058 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1059 CacheView *restrict cache_view,const VirtualPixelMethod virtual_pixel_method)
1061 assert(cache_view != (CacheView *) NULL);
1062 assert(cache_view->signature == MagickSignature);
1063 if (cache_view->debug != MagickFalse)
1064 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1065 cache_view->image->filename);
1066 cache_view->virtual_pixel_method=virtual_pixel_method;
1071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1075 % 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 %
1079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1081 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1082 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1083 % otherwise MagickFalse.
1085 % The format of the SyncCacheViewAuthenticPixels method is:
1087 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1088 % ExceptionInfo *exception)
1090 % A description of each parameter follows:
1092 % o cache_view: the cache view.
1094 % o exception: return any errors or warnings in this structure.
1097 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1098 CacheView *restrict cache_view,ExceptionInfo *exception)
1101 id = GetOpenMPThreadId();
1106 assert(cache_view != (CacheView *) NULL);
1107 assert(cache_view->signature == MagickSignature);
1108 assert(id < (int) cache_view->number_threads);
1109 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1110 cache_view->nexus_info[id],exception);