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-2018 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 % https://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 *magick_restrict cache_view;
118 cache_view=AcquireVirtualCacheView(image,exception);
123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 % A c q u i r e V i r t u a l C a c h e V i e w %
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 % AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
134 % using the VirtualPixelMethod that is defined within the given image itself.
135 % It always succeeds but may return a warning or informational exception.
137 % The format of the AcquireVirtualCacheView method is:
139 % CacheView *AcquireVirtualCacheView(const Image *image,
140 % ExceptionInfo *exception)
142 % A description of each parameter follows:
144 % o image: the image.
146 % o exception: return any errors or warnings in this structure.
149 MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
150 ExceptionInfo *exception)
153 *magick_restrict cache_view;
155 magick_unreferenced(exception);
156 assert(image != (Image *) NULL);
157 assert(image->signature == MagickCoreSignature);
158 if (image->debug != MagickFalse)
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
160 #if defined(MAGICKCORE_OPENCL_SUPPORT)
161 SyncAuthenticOpenCLBuffer(image);
163 cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
164 sizeof(*cache_view)));
165 if (cache_view == (CacheView *) NULL)
166 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
167 (void) memset(cache_view,0,sizeof(*cache_view));
168 cache_view->image=ReferenceImage((Image *) image);
169 cache_view->number_threads=GetOpenMPMaximumThreads();
170 if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
171 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
172 if (cache_view->number_threads == 0)
173 cache_view->number_threads=1;
174 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
175 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
176 cache_view->debug=IsEventLogging();
177 cache_view->signature=MagickCoreSignature;
178 if (cache_view->nexus_info == (NexusInfo **) NULL)
179 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188 % C l o n e C a c h e V i e w %
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194 % CloneCacheView() makes an exact copy of the specified cache view.
196 % The format of the CloneCacheView method is:
198 % CacheView *CloneCacheView(const CacheView *cache_view)
200 % A description of each parameter follows:
202 % o cache_view: the cache view.
205 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
208 *magick_restrict clone_view;
210 assert(cache_view != (CacheView *) NULL);
211 assert(cache_view->signature == MagickCoreSignature);
212 if (cache_view->debug != MagickFalse)
213 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
214 cache_view->image->filename);
215 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
216 sizeof(*clone_view)));
217 if (clone_view == (CacheView *) NULL)
218 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
219 (void) memset(clone_view,0,sizeof(*clone_view));
220 clone_view->image=ReferenceImage(cache_view->image);
221 clone_view->number_threads=cache_view->number_threads;
222 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
223 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
224 clone_view->debug=cache_view->debug;
225 clone_view->signature=MagickCoreSignature;
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 % D e s t r o y C a c h e V i e w %
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 % DestroyCacheView() destroys the specified view returned by a previous call
241 % to AcquireCacheView().
243 % The format of the DestroyCacheView method is:
245 % CacheView *DestroyCacheView(CacheView *cache_view)
247 % A description of each parameter follows:
249 % o cache_view: the cache view.
252 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
254 assert(cache_view != (CacheView *) NULL);
255 assert(cache_view->signature == MagickCoreSignature);
256 if (cache_view->debug != MagickFalse)
257 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
258 cache_view->image->filename);
259 if (cache_view->nexus_info != (NexusInfo **) NULL)
260 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
261 cache_view->number_threads);
262 cache_view->image=DestroyImage(cache_view->image);
263 cache_view->signature=(~MagickCoreSignature);
264 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 % 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 %
277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279 % GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
280 % cache as defined by the geometry parameters. A pointer to the pixels is
281 % returned if the pixels are transferred, otherwise a NULL is returned.
283 % The format of the GetCacheViewAuthenticPixels method is:
285 % Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
286 % const ssize_t x,const ssize_t y,const size_t columns,
287 % const size_t rows,ExceptionInfo *exception)
289 % A description of each parameter follows:
291 % o cache_view: the cache view.
293 % o x,y,columns,rows: These values define the perimeter of a region of
296 % o exception: return any errors or warnings in this structure.
299 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
300 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
301 ExceptionInfo *exception)
304 id = GetOpenMPThreadId();
307 *magick_restrict pixels;
309 assert(cache_view != (CacheView *) NULL);
310 assert(cache_view->signature == MagickCoreSignature);
311 assert(id < (int) cache_view->number_threads);
312 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
313 cache_view->nexus_info[id],exception);
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322 % 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 %
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 % GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
329 % with the last call to SetCacheViewIndexes() or
330 % GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
333 % The format of the GetCacheViewAuthenticMetacontent() method is:
335 % void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
337 % A description of each parameter follows:
339 % o cache_view: the cache view.
342 MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
345 id = GetOpenMPThreadId();
347 assert(cache_view != (CacheView *) NULL);
348 assert(cache_view->signature == MagickCoreSignature);
349 assert(cache_view->image->cache != (Cache) NULL);
350 assert(id < (int) cache_view->number_threads);
351 return(cache_view->nexus_info[id]->metacontent);
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
359 % 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 %
363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365 % GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
366 % last call to QueueCacheViewAuthenticPixels() or
367 % GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
370 % The format of the GetCacheViewAuthenticPixelQueue() method is:
372 % Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
374 % A description of each parameter follows:
376 % o cache_view: the cache view.
379 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
382 id = GetOpenMPThreadId();
384 assert(cache_view != (CacheView *) NULL);
385 assert(cache_view->signature == MagickCoreSignature);
386 assert(cache_view->image->cache != (Cache) NULL);
387 assert(id < (int) cache_view->number_threads);
388 return(cache_view->nexus_info[id]->pixels);
392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
396 % G e t C a c h e V i e w C o l o r s p a c e %
400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402 % GetCacheViewColorspace() returns the image colorspace associated with the
405 % The format of the GetCacheViewColorspace method is:
407 % ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
409 % A description of each parameter follows:
411 % o cache_view: the cache view.
414 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
416 assert(cache_view != (CacheView *) NULL);
417 assert(cache_view->signature == MagickCoreSignature);
418 if (cache_view->debug != MagickFalse)
419 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
420 cache_view->image->filename);
421 return(GetPixelCacheColorspace(cache_view->image->cache));
425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429 + G e t C a c h e V i e w E x t e n t %
433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
435 % GetCacheViewExtent() returns the extent of the pixels associated with the
436 % last call to QueueCacheViewAuthenticPixels() or
437 % GetCacheViewAuthenticPixels().
439 % The format of the GetCacheViewExtent() method is:
441 % MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
443 % A description of each parameter follows:
445 % o cache_view: the cache view.
448 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
451 id = GetOpenMPThreadId();
456 assert(cache_view != (CacheView *) NULL);
457 assert(cache_view->signature == MagickCoreSignature);
458 if (cache_view->debug != MagickFalse)
459 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
460 cache_view->image->filename);
461 assert(cache_view->image->cache != (Cache) NULL);
462 assert(id < (int) cache_view->number_threads);
463 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
464 cache_view->nexus_info[id]);
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473 % G e t C a c h e V i e w I m a g e %
477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
479 % GetCacheViewImage() returns the image associated with the specified view.
481 % The format of the GetCacheViewImage method is:
483 % const Image *GetCacheViewImage(const CacheView *cache_view)
485 % A description of each parameter follows:
487 % o cache_view: the cache view.
490 MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
492 assert(cache_view != (CacheView *) NULL);
493 assert(cache_view->signature == MagickCoreSignature);
494 if (cache_view->debug != MagickFalse)
495 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
496 cache_view->image->filename);
497 return(cache_view->image);
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 % G e t C a c h e V i e w S t o r a g e C l a s s %
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 % GetCacheViewStorageClass() returns the image storage class associated with
512 % the specified view.
514 % The format of the GetCacheViewStorageClass method is:
516 % ClassType GetCacheViewStorageClass(const CacheView *cache_view)
518 % A description of each parameter follows:
520 % o cache_view: the cache view.
523 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
525 assert(cache_view != (CacheView *) NULL);
526 assert(cache_view->signature == MagickCoreSignature);
527 if (cache_view->debug != MagickFalse)
528 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
529 cache_view->image->filename);
530 return(GetPixelCacheStorageClass(cache_view->image->cache));
534 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538 % 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 %
542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 % GetCacheViewVirtualMetacontent() returns the meta-content corresponding
545 % with the last call to GetCacheViewVirtualMetacontent(). The meta-content
546 % is virtual and therefore cannot be updated.
548 % The format of the GetCacheViewVirtualMetacontent() method is:
550 % const void *GetCacheViewVirtualMetacontent(
551 % const CacheView *cache_view)
553 % A description of each parameter follows:
555 % o cache_view: the cache view.
558 MagickExport const void *GetCacheViewVirtualMetacontent(
559 const CacheView *cache_view)
562 id = GetOpenMPThreadId();
565 *magick_restrict metacontent;
567 assert(cache_view != (const CacheView *) NULL);
568 assert(cache_view->signature == MagickCoreSignature);
569 assert(cache_view->image->cache != (Cache) NULL);
570 assert(id < (int) cache_view->number_threads);
571 metacontent=GetVirtualMetacontentFromNexus(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 Q u e u e %
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587 % GetCacheViewVirtualPixelQueue() returns the the pixels associated with
588 % the last call to GetCacheViewVirtualPixels(). The pixels are virtual
589 % and therefore cannot be updated.
591 % The format of the GetCacheViewVirtualPixelQueue() method is:
593 % const Quantum *GetCacheViewVirtualPixelQueue(
594 % const CacheView *cache_view)
596 % A description of each parameter follows:
598 % o cache_view: the cache view.
601 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
602 const CacheView *cache_view)
605 id = GetOpenMPThreadId();
608 *magick_restrict pixels;
610 assert(cache_view != (const CacheView *) NULL);
611 assert(cache_view->signature == MagickCoreSignature);
612 assert(cache_view->image->cache != (Cache) NULL);
613 assert(id < (int) cache_view->number_threads);
614 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
615 cache_view->nexus_info[id]);
620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
624 % 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 %
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 % GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
631 % disk pixel cache as defined by the geometry parameters. A pointer to the
632 % pixels is returned if the pixels are transferred, otherwise a NULL is
635 % The format of the GetCacheViewVirtualPixels method is:
637 % const Quantum *GetCacheViewVirtualPixels(
638 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
639 % const size_t columns,const size_t rows,ExceptionInfo *exception)
641 % A description of each parameter follows:
643 % o cache_view: the cache view.
645 % o x,y,columns,rows: These values define the perimeter of a region of
648 % o exception: return any errors or warnings in this structure.
651 MagickExport const Quantum *GetCacheViewVirtualPixels(
652 const CacheView *cache_view,const ssize_t x,const ssize_t y,
653 const size_t columns,const size_t rows,ExceptionInfo *exception)
656 id = GetOpenMPThreadId();
659 *magick_restrict pixels;
661 assert(cache_view != (CacheView *) NULL);
662 assert(cache_view->signature == MagickCoreSignature);
663 assert(id < (int) cache_view->number_threads);
664 pixels=GetVirtualPixelCacheNexus(cache_view->image,
665 cache_view->virtual_pixel_method,x,y,columns,rows,
666 cache_view->nexus_info[id],exception);
671 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
675 % 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 %
679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
681 % GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
682 % location. The image background color is returned if an error occurs.
684 % The format of the GetOneCacheViewAuthenticPixel method is:
686 % MagickBooleaNType GetOneCacheViewAuthenticPixel(
687 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
688 % Quantum *pixel,ExceptionInfo *exception)
690 % A description of each parameter follows:
692 % o cache_view: the cache view.
694 % o x,y: These values define the offset of the pixel.
696 % o pixel: return a pixel at the specified (x,y) location.
698 % o exception: return any errors or warnings in this structure.
701 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
702 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
703 ExceptionInfo *exception)
706 id = GetOpenMPThreadId();
714 assert(cache_view != (CacheView *) NULL);
715 assert(cache_view->signature == MagickCoreSignature);
716 assert(id < (int) cache_view->number_threads);
717 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
718 q=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
719 cache_view->nexus_info[id],exception);
720 if (q == (const Quantum *) NULL)
725 background_color=cache_view->image->background_color;
726 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
727 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
728 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
729 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
730 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
733 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
735 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
742 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
746 % 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 %
750 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
752 % GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
753 % location. The image background color is returned if an error occurs. If
754 % you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
756 % The format of the GetOneCacheViewVirtualPixel method is:
758 % MagickBooleanType GetOneCacheViewVirtualPixel(
759 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
760 % Quantum *pixel,ExceptionInfo *exception)
762 % A description of each parameter follows:
764 % o cache_view: the cache view.
766 % o x,y: These values define the offset of the pixel.
768 % o pixel: return a pixel at the specified (x,y) location.
770 % o exception: return any errors or warnings in this structure.
773 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
774 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
775 ExceptionInfo *exception)
778 id = GetOpenMPThreadId();
780 register const Quantum
786 assert(cache_view != (CacheView *) NULL);
787 assert(cache_view->signature == MagickCoreSignature);
788 assert(id < (int) cache_view->number_threads);
789 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
790 p=GetVirtualPixelCacheNexus(cache_view->image,
791 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
793 if (p == (const Quantum *) NULL)
798 background_color=cache_view->image->background_color;
799 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
800 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
801 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
802 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
803 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
806 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
808 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
819 % 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 %
823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825 % GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
826 % (x,y) location. The image background color is returned if an error occurs.
827 % If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
829 % The format of the GetOneCacheViewVirtualPixelInfo method is:
831 % MagickBooleanType GetOneCacheViewVirtualPixelInfo(
832 % const CacheView *cache_view,const ssize_t x,const ssize_t y,
833 % PixelInfo *pixel,ExceptionInfo *exception)
835 % A description of each parameter follows:
837 % o cache_view: the cache view.
839 % o x,y: These values define the offset of the pixel.
841 % o pixel: return a pixel at the specified (x,y) location.
843 % o exception: return any errors or warnings in this structure.
846 MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
847 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
848 ExceptionInfo *exception)
851 id = GetOpenMPThreadId();
853 register const Quantum
856 assert(cache_view != (CacheView *) NULL);
857 assert(cache_view->signature == MagickCoreSignature);
858 assert(id < (int) cache_view->number_threads);
859 GetPixelInfo(cache_view->image,pixel);
860 p=GetVirtualPixelCacheNexus(cache_view->image,
861 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
863 if (p == (const Quantum *) NULL)
865 GetPixelInfoPixel(cache_view->image,p,pixel);
870 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
874 % 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 %
878 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880 % GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
881 % the specified (x,y) location. The image background color is returned if an
882 % error occurs. If you plan to modify the pixel, use
883 % GetOneCacheViewAuthenticPixel() instead.
885 % The format of the GetOneCacheViewVirtualPixel method is:
887 % MagickBooleanType GetOneCacheViewVirtualMethodPixel(
888 % const CacheView *cache_view,
889 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
890 % const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
892 % A description of each parameter follows:
894 % o cache_view: the cache view.
896 % o virtual_pixel_method: the virtual pixel method.
898 % o x,y: These values define the offset of the pixel.
900 % o pixel: return a pixel at the specified (x,y) location.
902 % o exception: return any errors or warnings in this structure.
905 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
906 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
907 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
910 id = GetOpenMPThreadId();
918 assert(cache_view != (CacheView *) NULL);
919 assert(cache_view->signature == MagickCoreSignature);
920 assert(id < (int) cache_view->number_threads);
921 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
922 p=GetVirtualPixelCacheNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
923 cache_view->nexus_info[id],exception);
924 if (p == (const Quantum *) NULL)
929 background_color=cache_view->image->background_color;
930 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
931 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
932 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
933 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
934 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
937 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
939 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950 % 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 %
954 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
956 % QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
957 % disk pixel cache as defined by the geometry parameters. A pointer to the
958 % pixels is returned if the pixels are transferred, otherwise a NULL is
961 % The format of the QueueCacheViewAuthenticPixels method is:
963 % Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
964 % const ssize_t x,const ssize_t y,const size_t columns,
965 % const size_t rows,ExceptionInfo *exception)
967 % A description of each parameter follows:
969 % o cache_view: the cache view.
971 % o x,y,columns,rows: These values define the perimeter of a region of
974 % o exception: return any errors or warnings in this structure.
977 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
978 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
979 ExceptionInfo *exception)
982 id = GetOpenMPThreadId();
985 *magick_restrict pixels;
987 assert(cache_view != (CacheView *) NULL);
988 assert(cache_view->signature == MagickCoreSignature);
989 assert(id < (int) cache_view->number_threads);
990 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
991 MagickFalse,cache_view->nexus_info[id],exception);
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000 % S e t C a c h e V i e w S t o r a g e C l a s s %
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 % SetCacheViewStorageClass() sets the image storage class associated with
1007 % the specified view.
1009 % The format of the SetCacheViewStorageClass method is:
1011 % MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1012 % const ClassType storage_class,ExceptionInfo *exception)
1014 % A description of each parameter follows:
1016 % o cache_view: the cache view.
1018 % o storage_class: the image storage class: PseudoClass or DirectClass.
1020 % o exception: return any errors or warnings in this structure.
1023 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1024 const ClassType storage_class,ExceptionInfo *exception)
1026 assert(cache_view != (CacheView *) NULL);
1027 assert(cache_view->signature == MagickCoreSignature);
1028 if (cache_view->debug != MagickFalse)
1029 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1030 cache_view->image->filename);
1031 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1039 % 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 %
1043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1045 % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1046 % with the specified cache view.
1048 % The format of the SetCacheViewVirtualPixelMethod method is:
1050 % MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1051 % const VirtualPixelMethod virtual_pixel_method)
1053 % A description of each parameter follows:
1055 % o cache_view: the cache view.
1057 % o virtual_pixel_method: the virtual pixel method.
1060 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1061 CacheView *magick_restrict cache_view,
1062 const VirtualPixelMethod virtual_pixel_method)
1064 assert(cache_view != (CacheView *) NULL);
1065 assert(cache_view->signature == MagickCoreSignature);
1066 if (cache_view->debug != MagickFalse)
1067 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1068 cache_view->image->filename);
1069 cache_view->virtual_pixel_method=virtual_pixel_method;
1074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1078 % 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 %
1082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1084 % SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1085 % or disk cache. It returns MagickTrue if the pixel region is flushed,
1086 % otherwise MagickFalse.
1088 % The format of the SyncCacheViewAuthenticPixels method is:
1090 % MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1091 % ExceptionInfo *exception)
1093 % A description of each parameter follows:
1095 % o cache_view: the cache view.
1097 % o exception: return any errors or warnings in this structure.
1100 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1101 CacheView *magick_restrict cache_view,ExceptionInfo *exception)
1104 id = GetOpenMPThreadId();
1109 assert(cache_view != (CacheView *) NULL);
1110 assert(cache_view->signature == MagickCoreSignature);
1111 assert(id < (int) cache_view->number_threads);
1112 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1113 cache_view->nexus_info[id],exception);