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