MagickCore 7.1.1
Convert, Edit, Or Compose Bitmap Images
Loading...
Searching...
No Matches
cache-view.c
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% CCCC AAA CCCC H H EEEEE %
7% C A A C H H E %
8% C AAAAA C HHHHH EEE %
9% C A A C H H E %
10% CCCC A A CCCC H H EEEEE %
11% %
12% V V IIIII EEEEE W W %
13% V V I E W W %
14% V V I EEE W W W %
15% V V I E WW WW %
16% V IIIII EEEEE W W %
17% %
18% %
19% MagickCore Cache View Methods %
20% %
21% Software Design %
22% Cristy %
23% February 2000 %
24% %
25% %
26% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
27% dedicated to making software imaging solutions freely available. %
28% %
29% You may not use this file except in compliance with the License. You may %
30% obtain a copy of the License at %
31% %
32% https://imagemagick.org/script/license.php %
33% %
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. %
39% %
40%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41%
42%
43%
44*/
45
46/*
47 Include declarations.
48*/
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"
61
62/*
63 Typedef declarations.
64*/
66{
67 Image
68 *image;
69
70 VirtualPixelMethod
71 virtual_pixel_method;
72
73 size_t
74 number_threads;
75
77 **nexus_info;
78
79 MagickBooleanType
80 debug;
81
82 size_t
83 signature;
84};
85
86/*
87%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88% %
89% %
90% %
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 %
92% %
93% %
94% %
95%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96%
97% AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
98% It always succeeds but may return a warning or informational exception.
99%
100% The format of the AcquireAuthenticCacheView method is:
101%
102% CacheView *AcquireAuthenticCacheView(const Image *image,
103% ExceptionInfo *exception)
104%
105% A description of each parameter follows:
106%
107% o image: the image.
108%
109% o exception: return any errors or warnings in this structure.
110%
111*/
112MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
113 ExceptionInfo *exception)
114{
116 *magick_restrict cache_view;
117
118 cache_view=AcquireVirtualCacheView(image,exception);
119 return(cache_view);
120}
121
122/*
123%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
124% %
125% %
126% %
127% A c q u i r e V i r t u a l C a c h e V i e w %
128% %
129% %
130% %
131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132%
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.
136%
137% The format of the AcquireVirtualCacheView method is:
138%
139% CacheView *AcquireVirtualCacheView(const Image *image,
140% ExceptionInfo *exception)
141%
142% A description of each parameter follows:
143%
144% o image: the image.
145%
146% o exception: return any errors or warnings in this structure.
147%
148*/
149MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
150 ExceptionInfo *magick_unused(exception))
151{
153 *magick_restrict cache_view;
154
155 magick_unreferenced(exception);
156 assert(image != (Image *) NULL);
157 assert(image->signature == MagickCoreSignature);
158 if (IsEventLogging() != MagickFalse)
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
160#if defined(MAGICKCORE_OPENCL_SUPPORT)
161 SyncAuthenticOpenCLBuffer(image);
162#endif
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=(GetLogEventMask() & CacheEvent) != 0 ? MagickTrue :
177 MagickFalse;
178 cache_view->signature=MagickCoreSignature;
179 if (cache_view->nexus_info == (NexusInfo **) NULL)
180 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
181 return(cache_view);
182}
183
184/*
185%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186% %
187% %
188% %
189% C l o n e C a c h e V i e w %
190% %
191% %
192% %
193%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194%
195% CloneCacheView() makes an exact copy of the specified cache view.
196%
197% The format of the CloneCacheView method is:
198%
199% CacheView *CloneCacheView(const CacheView *cache_view)
200%
201% A description of each parameter follows:
202%
203% o cache_view: the cache view.
204%
205*/
206MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
207{
209 *magick_restrict clone_view;
210
211 assert(cache_view != (CacheView *) NULL);
212 assert(cache_view->signature == MagickCoreSignature);
213 if (IsEventLogging() != MagickFalse)
214 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
215 cache_view->image->filename);
216 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
217 sizeof(*clone_view)));
218 if (clone_view == (CacheView *) NULL)
219 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
220 (void) memset(clone_view,0,sizeof(*clone_view));
221 clone_view->image=ReferenceImage(cache_view->image);
222 clone_view->number_threads=cache_view->number_threads;
223 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
224 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
225 clone_view->debug=cache_view->debug;
226 clone_view->signature=MagickCoreSignature;
227 return(clone_view);
228}
229
230/*
231%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232% %
233% %
234% %
235% D e s t r o y C a c h e V i e w %
236% %
237% %
238% %
239%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240%
241% DestroyCacheView() destroys the specified view returned by a previous call
242% to AcquireCacheView().
243%
244% The format of the DestroyCacheView method is:
245%
246% CacheView *DestroyCacheView(CacheView *cache_view)
247%
248% A description of each parameter follows:
249%
250% o cache_view: the cache view.
251%
252*/
253MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
254{
255 assert(cache_view != (CacheView *) NULL);
256 assert(cache_view->signature == MagickCoreSignature);
257 if (IsEventLogging() != MagickFalse)
258 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
259 cache_view->image->filename);
260 if (cache_view->nexus_info != (NexusInfo **) NULL)
261 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
262 cache_view->number_threads);
263 cache_view->image=DestroyImage(cache_view->image);
264 cache_view->signature=(~MagickCoreSignature);
265 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
266 return(cache_view);
267}
268
269/*
270%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271% %
272% %
273% %
274% 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% %
276% %
277% %
278%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
279%
280% GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
281% cache as defined by the geometry parameters. A pointer to the pixels is
282% returned if the pixels are transferred, otherwise a NULL is returned.
283%
284% The format of the GetCacheViewAuthenticPixels method is:
285%
286% Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
287% const ssize_t x,const ssize_t y,const size_t columns,
288% const size_t rows,ExceptionInfo *exception)
289%
290% A description of each parameter follows:
291%
292% o cache_view: the cache view.
293%
294% o x,y,columns,rows: These values define the perimeter of a region of
295% pixels.
296%
297% o exception: return any errors or warnings in this structure.
298%
299*/
300MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
301 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
302 ExceptionInfo *exception)
303{
304 const int
305 id = GetOpenMPThreadId();
306
307 Quantum
308 *magick_restrict pixels;
309
310 assert(cache_view != (CacheView *) NULL);
311 assert(cache_view->signature == MagickCoreSignature);
312 assert(id < (int) cache_view->number_threads);
313 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
314 cache_view->nexus_info[id],exception);
315 return(pixels);
316}
317
318/*
319%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320% %
321% %
322% %
323% 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% %
325% %
326% %
327%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328%
329% GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
330% with the last call to SetCacheViewIndexes() or
331% GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
332% be updated.
333%
334% The format of the GetCacheViewAuthenticMetacontent() method is:
335%
336% void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
337%
338% A description of each parameter follows:
339%
340% o cache_view: the cache view.
341%
342*/
343MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
344{
345 const int
346 id = GetOpenMPThreadId();
347
348 assert(cache_view != (CacheView *) NULL);
349 assert(cache_view->signature == MagickCoreSignature);
350 assert(cache_view->image->cache != (Cache) NULL);
351 assert(id < (int) cache_view->number_threads);
352 return(cache_view->nexus_info[id]->metacontent);
353}
354
355/*
356%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357% %
358% %
359% %
360% 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% %
362% %
363% %
364%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365%
366% GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
367% last call to QueueCacheViewAuthenticPixels() or
368% GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
369% updated.
370%
371% The format of the GetCacheViewAuthenticPixelQueue() method is:
372%
373% Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
374%
375% A description of each parameter follows:
376%
377% o cache_view: the cache view.
378%
379*/
380MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
381{
382 const int
383 id = GetOpenMPThreadId();
384
385 assert(cache_view != (CacheView *) NULL);
386 assert(cache_view->signature == MagickCoreSignature);
387 assert(cache_view->image->cache != (Cache) NULL);
388 assert(id < (int) cache_view->number_threads);
389 return(cache_view->nexus_info[id]->pixels);
390}
391
392/*
393%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394% %
395% %
396% %
397% G e t C a c h e V i e w C o l o r s p a c e %
398% %
399% %
400% %
401%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
402%
403% GetCacheViewColorspace() returns the image colorspace associated with the
404% specified view.
405%
406% The format of the GetCacheViewColorspace method is:
407%
408% ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
409%
410% A description of each parameter follows:
411%
412% o cache_view: the cache view.
413%
414*/
415MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
416{
417 assert(cache_view != (CacheView *) NULL);
418 assert(cache_view->signature == MagickCoreSignature);
419 if (IsEventLogging() != MagickFalse)
420 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
421 cache_view->image->filename);
422 return(GetPixelCacheColorspace(cache_view->image->cache));
423}
424
425/*
426%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427% %
428% %
429% %
430+ G e t C a c h e V i e w E x t e n t %
431% %
432% %
433% %
434%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
435%
436% GetCacheViewExtent() returns the extent of the pixels associated with the
437% last call to QueueCacheViewAuthenticPixels() or
438% GetCacheViewAuthenticPixels().
439%
440% The format of the GetCacheViewExtent() method is:
441%
442% MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
443%
444% A description of each parameter follows:
445%
446% o cache_view: the cache view.
447%
448*/
449MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
450{
451 const int
452 id = GetOpenMPThreadId();
453
454 MagickSizeType
455 extent;
456
457 assert(cache_view != (CacheView *) NULL);
458 assert(cache_view->signature == MagickCoreSignature);
459 if (IsEventLogging() != MagickFalse)
460 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
461 cache_view->image->filename);
462 assert(cache_view->image->cache != (Cache) NULL);
463 assert(id < (int) cache_view->number_threads);
464 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
465 cache_view->nexus_info[id]);
466 return(extent);
467}
468
469/*
470%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471% %
472% %
473% %
474% G e t C a c h e V i e w I m a g e %
475% %
476% %
477% %
478%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
479%
480% GetCacheViewImage() returns the image associated with the specified view.
481%
482% The format of the GetCacheViewImage method is:
483%
484% const Image *GetCacheViewImage(const CacheView *cache_view)
485%
486% A description of each parameter follows:
487%
488% o cache_view: the cache view.
489%
490*/
491MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
492{
493 assert(cache_view != (CacheView *) NULL);
494 assert(cache_view->signature == MagickCoreSignature);
495 if (IsEventLogging() != MagickFalse)
496 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
497 cache_view->image->filename);
498 return(cache_view->image);
499}
500
501/*
502%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503% %
504% %
505% %
506% 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% %
508% %
509% %
510%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511%
512% GetCacheViewStorageClass() returns the image storage class associated with
513% the specified view.
514%
515% The format of the GetCacheViewStorageClass method is:
516%
517% ClassType GetCacheViewStorageClass(const CacheView *cache_view)
518%
519% A description of each parameter follows:
520%
521% o cache_view: the cache view.
522%
523*/
524MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
525{
526 assert(cache_view != (CacheView *) NULL);
527 assert(cache_view->signature == MagickCoreSignature);
528 if (IsEventLogging() != MagickFalse)
529 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
530 cache_view->image->filename);
531 return(GetPixelCacheStorageClass(cache_view->image->cache));
532}
533
534/*
535%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536% %
537% %
538% %
539% 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% %
541% %
542% %
543%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544%
545% GetCacheViewVirtualMetacontent() returns the meta-content corresponding
546% with the last call to GetCacheViewVirtualMetacontent(). The meta-content
547% is virtual and therefore cannot be updated.
548%
549% The format of the GetCacheViewVirtualMetacontent() method is:
550%
551% const void *GetCacheViewVirtualMetacontent(
552% const CacheView *cache_view)
553%
554% A description of each parameter follows:
555%
556% o cache_view: the cache view.
557%
558*/
559MagickExport const void *GetCacheViewVirtualMetacontent(
560 const CacheView *cache_view)
561{
562 const int
563 id = GetOpenMPThreadId();
564
565 const void
566 *magick_restrict metacontent;
567
568 assert(cache_view != (const CacheView *) NULL);
569 assert(cache_view->signature == MagickCoreSignature);
570 assert(cache_view->image->cache != (Cache) NULL);
571 assert(id < (int) cache_view->number_threads);
572 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
573 cache_view->nexus_info[id]);
574 return(metacontent);
575}
576
577/*
578%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579% %
580% %
581% %
582% 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% %
584% %
585% %
586%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587%
588% GetCacheViewVirtualPixelQueue() returns the pixels associated with
589% the last call to GetCacheViewVirtualPixels(). The pixels are virtual
590% and therefore cannot be updated.
591%
592% The format of the GetCacheViewVirtualPixelQueue() method is:
593%
594% const Quantum *GetCacheViewVirtualPixelQueue(
595% const CacheView *cache_view)
596%
597% A description of each parameter follows:
598%
599% o cache_view: the cache view.
600%
601*/
602MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
603 const CacheView *cache_view)
604{
605 const int
606 id = GetOpenMPThreadId();
607
608 const Quantum
609 *magick_restrict pixels;
610
611 assert(cache_view != (const CacheView *) NULL);
612 assert(cache_view->signature == MagickCoreSignature);
613 assert(cache_view->image->cache != (Cache) NULL);
614 assert(id < (int) cache_view->number_threads);
615 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
616 cache_view->nexus_info[id]);
617 return(pixels);
618}
619
620/*
621%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622% %
623% %
624% %
625% 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% %
627% %
628% %
629%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630%
631% GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
632% disk pixel cache as defined by the geometry parameters. A pointer to the
633% pixels is returned if the pixels are transferred, otherwise a NULL is
634% returned.
635%
636% The format of the GetCacheViewVirtualPixels method is:
637%
638% const Quantum *GetCacheViewVirtualPixels(
639% const CacheView *cache_view,const ssize_t x,const ssize_t y,
640% const size_t columns,const size_t rows,ExceptionInfo *exception)
641%
642% A description of each parameter follows:
643%
644% o cache_view: the cache view.
645%
646% o x,y,columns,rows: These values define the perimeter of a region of
647% pixels.
648%
649% o exception: return any errors or warnings in this structure.
650%
651*/
652MagickExport const Quantum *GetCacheViewVirtualPixels(
653 const CacheView *cache_view,const ssize_t x,const ssize_t y,
654 const size_t columns,const size_t rows,ExceptionInfo *exception)
655{
656 const int
657 id = GetOpenMPThreadId();
658
659 const Quantum
660 *magick_restrict pixels;
661
662 assert(cache_view != (CacheView *) NULL);
663 assert(cache_view->signature == MagickCoreSignature);
664 assert(id < (int) cache_view->number_threads);
665 pixels=GetVirtualPixelCacheNexus(cache_view->image,
666 cache_view->virtual_pixel_method,x,y,columns,rows,
667 cache_view->nexus_info[id],exception);
668 return(pixels);
669}
670
671/*
672%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673% %
674% %
675% %
676% 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% %
678% %
679% %
680%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
681%
682% GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
683% location. The image background color is returned if an error occurs.
684%
685% The format of the GetOneCacheViewAuthenticPixel method is:
686%
687% MagickBooleanType GetOneCacheViewAuthenticPixel(
688% const CacheView *cache_view,const ssize_t x,const ssize_t y,
689% Quantum *pixel,ExceptionInfo *exception)
690%
691% A description of each parameter follows:
692%
693% o cache_view: the cache view.
694%
695% o x,y: These values define the offset of the pixel.
696%
697% o pixel: return a pixel at the specified (x,y) location.
698%
699% o exception: return any errors or warnings in this structure.
700%
701*/
702MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
703 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
704 ExceptionInfo *exception)
705{
706 const int
707 id = GetOpenMPThreadId();
708
709 Quantum
710 *magick_restrict q;
711
712 ssize_t
713 i;
714
715 assert(cache_view != (CacheView *) NULL);
716 assert(cache_view->signature == MagickCoreSignature);
717 assert(id < (int) cache_view->number_threads);
718 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
719 q=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
720 cache_view->nexus_info[id],exception);
721 if (q == (const Quantum *) NULL)
722 {
724 background_color;
725
726 background_color=cache_view->image->background_color;
727 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
728 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
729 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
730 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
731 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
732 return(MagickFalse);
733 }
734 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
735 {
736 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
737 pixel[channel]=q[i];
738 }
739 return(MagickTrue);
740}
741
742/*
743%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
744% %
745% %
746% %
747% 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% %
749% %
750% %
751%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
752%
753% GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
754% location. The image background color is returned if an error occurs. If
755% you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
756%
757% The format of the GetOneCacheViewVirtualPixel method is:
758%
759% MagickBooleanType GetOneCacheViewVirtualPixel(
760% const CacheView *cache_view,const ssize_t x,const ssize_t y,
761% Quantum *pixel,ExceptionInfo *exception)
762%
763% A description of each parameter follows:
764%
765% o cache_view: the cache view.
766%
767% o x,y: These values define the offset of the pixel.
768%
769% o pixel: return a pixel at the specified (x,y) location.
770%
771% o exception: return any errors or warnings in this structure.
772%
773*/
774MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
775 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
776 ExceptionInfo *exception)
777{
778 const int
779 id = GetOpenMPThreadId();
780
781 const Quantum
782 *magick_restrict p;
783
784 ssize_t
785 i;
786
787 assert(cache_view != (CacheView *) NULL);
788 assert(cache_view->signature == MagickCoreSignature);
789 assert(id < (int) cache_view->number_threads);
790 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
791 p=GetVirtualPixelCacheNexus(cache_view->image,
792 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
793 exception);
794 if (p == (const Quantum *) NULL)
795 {
797 background_color;
798
799 background_color=cache_view->image->background_color;
800 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
801 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
802 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
803 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
804 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
805 return(MagickFalse);
806 }
807 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
808 {
809 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
810 pixel[channel]=p[i];
811 }
812 return(MagickTrue);
813}
814
815/*
816%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
817% %
818% %
819% %
820% 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% %
822% %
823% %
824%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825%
826% GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
827% (x,y) location. The image background color is returned if an error occurs.
828% If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
829%
830% The format of the GetOneCacheViewVirtualPixelInfo method is:
831%
832% MagickBooleanType GetOneCacheViewVirtualPixelInfo(
833% const CacheView *cache_view,const ssize_t x,const ssize_t y,
834% PixelInfo *pixel,ExceptionInfo *exception)
835%
836% A description of each parameter follows:
837%
838% o cache_view: the cache view.
839%
840% o x,y: These values define the offset of the pixel.
841%
842% o pixel: return a pixel at the specified (x,y) location.
843%
844% o exception: return any errors or warnings in this structure.
845%
846*/
847MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
848 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
849 ExceptionInfo *exception)
850{
851 const int
852 id = GetOpenMPThreadId();
853
854 const Quantum
855 *magick_restrict p;
856
857 assert(cache_view != (CacheView *) NULL);
858 assert(cache_view->signature == MagickCoreSignature);
859 assert(id < (int) cache_view->number_threads);
860 GetPixelInfo(cache_view->image,pixel);
861 p=GetVirtualPixelCacheNexus(cache_view->image,
862 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
863 exception);
864 if (p == (const Quantum *) NULL)
865 return(MagickFalse);
866 GetPixelInfoPixel(cache_view->image,p,pixel);
867 return(MagickTrue);
868}
869
870/*
871%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
872% %
873% %
874% %
875% 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% %
877% %
878% %
879%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880%
881% GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
882% the specified (x,y) location. The image background color is returned if an
883% error occurs. If you plan to modify the pixel, use
884% GetOneCacheViewAuthenticPixel() instead.
885%
886% The format of the GetOneCacheViewVirtualPixel method is:
887%
888% MagickBooleanType GetOneCacheViewVirtualMethodPixel(
889% const CacheView *cache_view,
890% const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
891% const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
892%
893% A description of each parameter follows:
894%
895% o cache_view: the cache view.
896%
897% o virtual_pixel_method: the virtual pixel method.
898%
899% o x,y: These values define the offset of the pixel.
900%
901% o pixel: return a pixel at the specified (x,y) location.
902%
903% o exception: return any errors or warnings in this structure.
904%
905*/
906MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
907 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
908 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
909{
910 const int
911 id = GetOpenMPThreadId();
912
913 const Quantum
914 *magick_restrict p;
915
916 ssize_t
917 i;
918
919 assert(cache_view != (CacheView *) NULL);
920 assert(cache_view->signature == MagickCoreSignature);
921 assert(id < (int) cache_view->number_threads);
922 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
923 p=GetVirtualPixelCacheNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
924 cache_view->nexus_info[id],exception);
925 if (p == (const Quantum *) NULL)
926 {
928 background_color;
929
930 background_color=cache_view->image->background_color;
931 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
932 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
933 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
934 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
935 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
936 return(MagickFalse);
937 }
938 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
939 {
940 PixelChannel channel = GetPixelChannelChannel(cache_view->image,i);
941 pixel[channel]=p[i];
942 }
943 return(MagickTrue);
944}
945
946/*
947%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948% %
949% %
950% %
951% 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% %
953% %
954% %
955%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
956%
957% QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
958% disk pixel cache as defined by the geometry parameters. A pointer to the
959% pixels is returned if the pixels are transferred, otherwise a NULL is
960% returned.
961%
962% The format of the QueueCacheViewAuthenticPixels method is:
963%
964% Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
965% const ssize_t x,const ssize_t y,const size_t columns,
966% const size_t rows,ExceptionInfo *exception)
967%
968% A description of each parameter follows:
969%
970% o cache_view: the cache view.
971%
972% o x,y,columns,rows: These values define the perimeter of a region of
973% pixels.
974%
975% o exception: return any errors or warnings in this structure.
976%
977*/
978MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
979 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
980 ExceptionInfo *exception)
981{
982 const int
983 id = GetOpenMPThreadId();
984
985 Quantum
986 *magick_restrict pixels;
987
988 assert(cache_view != (CacheView *) NULL);
989 assert(cache_view->signature == MagickCoreSignature);
990 assert(id < (int) cache_view->number_threads);
991 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
992 MagickFalse,cache_view->nexus_info[id],exception);
993 return(pixels);
994}
995
996/*
997%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998% %
999% %
1000% %
1001% 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% %
1003% %
1004% %
1005%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006%
1007% SetCacheViewStorageClass() sets the image storage class associated with
1008% the specified view.
1009%
1010% The format of the SetCacheViewStorageClass method is:
1011%
1012% MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1013% const ClassType storage_class,ExceptionInfo *exception)
1014%
1015% A description of each parameter follows:
1016%
1017% o cache_view: the cache view.
1018%
1019% o storage_class: the image storage class: PseudoClass or DirectClass.
1020%
1021% o exception: return any errors or warnings in this structure.
1022%
1023*/
1024MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
1025 const ClassType storage_class,ExceptionInfo *exception)
1026{
1027 assert(cache_view != (CacheView *) NULL);
1028 assert(cache_view->signature == MagickCoreSignature);
1029 if (IsEventLogging() != MagickFalse)
1030 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1031 cache_view->image->filename);
1032 return(SetImageStorageClass(cache_view->image,storage_class,exception));
1033}
1034
1035/*
1036%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1037% %
1038% %
1039% %
1040% 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% %
1042% %
1043% %
1044%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1045%
1046% SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1047% with the specified cache view.
1048%
1049% The format of the SetCacheViewVirtualPixelMethod method is:
1050%
1051% MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1052% const VirtualPixelMethod virtual_pixel_method)
1053%
1054% A description of each parameter follows:
1055%
1056% o cache_view: the cache view.
1057%
1058% o virtual_pixel_method: the virtual pixel method.
1059%
1060*/
1061MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
1062 CacheView *magick_restrict cache_view,
1063 const VirtualPixelMethod virtual_pixel_method)
1064{
1065 assert(cache_view != (CacheView *) NULL);
1066 assert(cache_view->signature == MagickCoreSignature);
1067 if (IsEventLogging() != MagickFalse)
1068 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1069 cache_view->image->filename);
1070 cache_view->virtual_pixel_method=virtual_pixel_method;
1071 return(MagickTrue);
1072}
1073
1074/*
1075%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1076% %
1077% %
1078% %
1079% 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 %
1080% %
1081% %
1082% %
1083%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1084%
1085% SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1086% or disk cache. It returns MagickTrue if the pixel region is flushed,
1087% otherwise MagickFalse.
1088%
1089% The format of the SyncCacheViewAuthenticPixels method is:
1090%
1091% MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1092% ExceptionInfo *exception)
1093%
1094% A description of each parameter follows:
1095%
1096% o cache_view: the cache view.
1097%
1098% o exception: return any errors or warnings in this structure.
1099%
1100*/
1101MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1102 CacheView *magick_restrict cache_view,ExceptionInfo *exception)
1103{
1104 const int
1105 id = GetOpenMPThreadId();
1106
1107 MagickBooleanType
1108 status;
1109
1110 assert(cache_view != (CacheView *) NULL);
1111 assert(cache_view->signature == MagickCoreSignature);
1112 assert(id < (int) cache_view->number_threads);
1113 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1114 cache_view->nexus_info[id],exception);
1115 return(status);
1116}