blob: 20adb040c58b83d5258dc82b8d5395c3256d766c [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% John Cristy %
23% February 2000 %
24% %
25% %
26% Copyright 1999-2009 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% http://www.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 "magick/studio.h"
50#include "magick/cache.h"
51#include "magick/cache-private.h"
52#include "magick/cache-view.h"
53#include "magick/memory_.h"
54#include "magick/exception.h"
55#include "magick/exception-private.h"
56#include "magick/string_.h"
57#include "magick/thread-private.h"
58
59/*
60 Typedef declarations.
61*/
62struct _CacheView
63{
64 Image
65 *image;
66
67 VirtualPixelMethod
68 virtual_pixel_method;
69
70 unsigned long
71 number_threads;
72
73 NexusInfo
74 **nexus_info;
75
76 MagickBooleanType
77 debug;
78
79 unsigned long
80 signature;
81};
82
83/*
84%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85% %
86% %
87% %
88% A c q u i r e C a c h e V i e w %
89% %
90% %
91% %
92%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93%
94% AcquireCacheView() acquires a view into the pixel cache, using the
95% VirtualPixelMethod that is defined within the given image itself.
96%
97% The format of the AcquireCacheView method is:
98%
99% CacheView *AcquireCacheView(const Image *image)
100%
101% A description of each parameter follows:
102%
103% o image: the image.
104%
105*/
106MagickExport CacheView *AcquireCacheView(const Image *image)
107{
108 CacheView
109 *cache_view;
110
111 assert(image != (Image *) NULL);
112 assert(image->signature == MagickSignature);
113 if (image->debug != MagickFalse)
114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
115 cache_view=(CacheView *) AcquireAlignedMemory(1,sizeof(*cache_view));
116 if (cache_view == (CacheView *) NULL)
117 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
118 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
119 cache_view->image=ReferenceImage((Image *) image);
120 cache_view->number_threads=GetOpenMPMaximumThreads();
121 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
122 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
123 cache_view->debug=IsEventLogging();
124 cache_view->signature=MagickSignature;
125 if (cache_view->nexus_info == (NexusInfo **) NULL)
126 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
127 return(cache_view);
128}
129
130/*
131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132% %
133% %
134% %
135% C l o n e C a c h e V i e w %
136% %
137% %
138% %
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140%
141% CloneCacheView() makes an exact copy of the specified cache view.
142%
143% The format of the CloneCacheView method is:
144%
145% CacheView *CloneCacheView(const CacheView *cache_view)
146%
147% A description of each parameter follows:
148%
149% o cache_view: the cache view.
150%
151*/
152MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
153{
154 CacheView
155 *clone_view;
156
157 assert(cache_view != (CacheView *) NULL);
158 assert(cache_view->signature == MagickSignature);
159 if (cache_view->debug != MagickFalse)
160 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
161 cache_view->image->filename);
162 clone_view=(CacheView *) AcquireAlignedMemory(1,sizeof(*clone_view));
163 if (clone_view == (CacheView *) NULL)
164 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
165 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
166 clone_view->image=ReferenceImage(cache_view->image);
167 clone_view->number_threads=cache_view->number_threads;
168 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
169 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
170 clone_view->debug=cache_view->debug;
171 clone_view->signature=MagickSignature;
172 return(clone_view);
173}
174
175/*
176%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177% %
178% %
179% %
180% D e s t r o y C a c h e V i e w %
181% %
182% %
183% %
184%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185%
186% DestroyCacheView() destroys the specified view returned by a previous call
187% to AcquireCacheView().
188%
189% The format of the DestroyCacheView method is:
190%
191% CacheView *DestroyCacheView(CacheView *cache_view)
192%
193% A description of each parameter follows:
194%
195% o cache_view: the cache view.
196%
197*/
198MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
199{
200 assert(cache_view != (CacheView *) NULL);
201 assert(cache_view->signature == MagickSignature);
202 if (cache_view->debug != MagickFalse)
203 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
204 cache_view->image->filename);
205 if (cache_view->nexus_info != (NexusInfo **) NULL)
206 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
207 cache_view->number_threads);
208 cache_view->image=DestroyImage(cache_view->image);
209 cache_view->signature=(~MagickSignature);
210 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
211 return(cache_view);
212}
213
214/*
215%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216% %
217% %
218% %
219% G e t C a c h e V i e w C o l o r s p a c e %
220% %
221% %
222% %
223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224%
225% GetCacheViewColorspace() returns the image colorspace associated with the
226% specified view.
227%
228% The format of the GetCacheViewColorspace method is:
229%
230% ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
231%
232% A description of each parameter follows:
233%
234% o cache_view: the cache view.
235%
236*/
237MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
238{
239 assert(cache_view != (CacheView *) NULL);
240 assert(cache_view->signature == MagickSignature);
241 if (cache_view->debug != MagickFalse)
242 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
243 cache_view->image->filename);
244 return(cache_view->image->colorspace);
245}
246
247/*
248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249% %
250% %
251% %
252% G e t C a c h e V i e w E x c e p t i o n %
253% %
254% %
255% %
256%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257%
258% GetCacheViewException() returns the image exception associated with the
259% specified view.
260%
261% The format of the GetCacheViewException method is:
262%
263% ExceptionInfo GetCacheViewException(const CacheView *cache_view)
264%
265% A description of each parameter follows:
266%
267% o cache_view: the cache view.
268%
269*/
270MagickExport ExceptionInfo *GetCacheViewException(const CacheView *cache_view)
271{
272 assert(cache_view != (CacheView *) NULL);
273 assert(cache_view->signature == MagickSignature);
274 if (cache_view->debug != MagickFalse)
275 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
276 cache_view->image->filename);
277 return(&cache_view->image->exception);
278}
279
280/*
281%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282% %
283% %
284% %
285+ G e t C a c h e V i e w E x t e n t %
286% %
287% %
288% %
289%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290%
291% GetCacheViewExtent() returns the extent of the pixels associated with the
292% last call to QueueCacheViewAuthenticPixels() or
293% GetCacheViewAuthenticPixels().
294%
295% The format of the GetCacheViewExtent() method is:
296%
297% MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
298%
299% A description of each parameter follows:
300%
301% o cache_view: the cache view.
302%
303*/
304MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
305{
306 long
307 id;
308
309 MagickSizeType
310 extent;
311
312 assert(cache_view != (CacheView *) NULL);
313 assert(cache_view->signature == MagickSignature);
314 if (cache_view->debug != MagickFalse)
315 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
316 cache_view->image->filename);
317 assert(cache_view->image->cache != (Cache) NULL);
318 id=GetOpenMPThreadId();
319 assert(id < (long) cache_view->number_threads);
320 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
321 cache_view->nexus_info[id]);
322 return(extent);
323}
324
325/*
326%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327% %
328% %
329% %
330% G e t C a c h e V i e w S t o r a g e C l a s s %
331% %
332% %
333% %
334%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335%
336% GetCacheViewStorageClass() returns the image storage class associated with
337% the specified view.
338%
339% The format of the GetCacheViewStorageClass method is:
340%
341% ClassType GetCacheViewStorageClass(const CacheView *cache_view)
342%
343% A description of each parameter follows:
344%
345% o cache_view: the cache view.
346%
347*/
348MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
349{
350 assert(cache_view != (CacheView *) NULL);
351 assert(cache_view->signature == MagickSignature);
352 if (cache_view->debug != MagickFalse)
353 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
354 cache_view->image->filename);
355 return(cache_view->image->storage_class);
356}
357
358/*
359%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
360% %
361% %
362% %
363% G e t C a c h e V i e w A u t h e n t i c P i x e l s %
364% %
365% %
366% %
367%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368%
369% GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
370% cache as defined by the geometry parameters. A pointer to the pixels is
371% returned if the pixels are transferred, otherwise a NULL is returned.
372%
373% The format of the GetCacheViewAuthenticPixels method is:
374%
375% PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
376% const long x,const long y,const unsigned long columns,
377% const unsigned long rows,ExceptionInfo *exception)
378%
379% A description of each parameter follows:
380%
381% o cache_view: the cache view.
382%
383% o x,y,columns,rows: These values define the perimeter of a region of
384% pixels.
385%
386*/
387MagickExport PixelPacket *GetCacheViewAuthenticPixels(CacheView *cache_view,
388 const long x,const long y,const unsigned long columns,
389 const unsigned long rows,ExceptionInfo *exception)
390{
391 Cache
392 cache;
393
394 long
395 id;
396
397 PixelPacket
398 *pixels;
399
400 assert(cache_view != (CacheView *) NULL);
401 assert(cache_view->signature == MagickSignature);
402 if (cache_view->debug != MagickFalse)
403 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
404 cache_view->image->filename);
405 cache=GetImagePixelCache(cache_view->image,MagickTrue,exception);
406 if (cache == (Cache) NULL)
407 return((PixelPacket *) NULL);
408 id=GetOpenMPThreadId();
409 assert(id < (long) cache_view->number_threads);
410 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
411 cache_view->nexus_info[id],exception);
412 return(pixels);
413}
414
415/*
416%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417% %
418% %
419% %
420% 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 %
421% %
422% %
423% %
424%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425%
426% GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
427% location. The image background color is returned if an error occurs.
428%
429% The format of the GetOneCacheViewAuthenticPixel method is:
430%
431% MagickBooleaNType GetOneCacheViewAuthenticPixel(
432% const CacheView *cache_view,const long x,const long y,
433% Pixelpacket *pixel,ExceptionInfo *exception)
434%
435% A description of each parameter follows:
436%
437% o cache_view: the cache view.
438%
439% o x,y: These values define the offset of the pixel.
440%
441% o pixel: return a pixel at the specified (x,y) location.
442%
443% o exception: return any errors or warnings in this structure.
444%
445*/
446MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
447 const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
448 ExceptionInfo *exception)
449{
450 Cache
451 cache;
452
453 long
454 id;
455
456 PixelPacket
457 *pixels;
458
459 assert(cache_view != (CacheView *) NULL);
460 assert(cache_view->signature == MagickSignature);
461 if (cache_view->debug != MagickFalse)
462 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
463 cache_view->image->filename);
464 cache=GetImagePixelCache(cache_view->image,MagickTrue,exception);
465 if (cache == (Cache) NULL)
466 return(MagickFalse);
467 *pixel=cache_view->image->background_color;
468 id=GetOpenMPThreadId();
469 assert(id < (long) cache_view->number_threads);
470 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
471 cache_view->nexus_info[id],exception);
472 if (pixels == (const PixelPacket *) NULL)
473 return(MagickFalse);
474 *pixel=(*pixels);
475 return(MagickTrue);
476}
477
478/*
479%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480% %
481% %
482% %
483% G e t C a c h e V i e w A u t h e n t i c I n d e x Q u e u e %
484% %
485% %
486% %
487%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
488%
489% GetCacheViewAuthenticIndexQueue() returns the indexes associated with the
490% last call to SetCacheViewIndexes() or GetCacheViewAuthenticIndexQueue(). The
491% indexes are authentic and can be updated.
492%
493% The format of the GetCacheViewAuthenticIndexQueue() method is:
494%
495% IndexPacket *GetCacheViewAuthenticIndexQueue(CacheView *cache_view)
496%
497% A description of each parameter follows:
498%
499% o cache_view: the cache view.
500%
501*/
502MagickExport IndexPacket *GetCacheViewAuthenticIndexQueue(CacheView *cache_view)
503{
504 IndexPacket
505 *indexes;
506
507 long
508 id;
509
510 assert(cache_view != (CacheView *) NULL);
511 assert(cache_view->signature == MagickSignature);
512 if (cache_view->debug != MagickFalse)
513 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
514 cache_view->image->filename);
515 assert(cache_view->image->cache != (Cache) NULL);
516 id=GetOpenMPThreadId();
517 assert(id < (long) cache_view->number_threads);
518 indexes=GetPixelCacheNexusIndexes(cache_view->image->cache,
519 cache_view->nexus_info[id]);
520 return(indexes);
521}
522
523/*
524%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525% %
526% %
527% %
528% 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 %
529% %
530% %
531% %
532%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533%
534% GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
535% last call to QueueCacheViewAuthenticPixels() or
536% GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
537% updated.
538%
539% The format of the GetCacheViewAuthenticPixelQueue() method is:
540%
541% PixelPacket *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
542%
543% A description of each parameter follows:
544%
545% o cache_view: the cache view.
546%
547*/
548MagickExport PixelPacket *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
549{
550 long
551 id;
552
553 PixelPacket
554 *pixels;
555
556 assert(cache_view != (CacheView *) NULL);
557 assert(cache_view->signature == MagickSignature);
558 if (cache_view->debug != MagickFalse)
559 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
560 cache_view->image->filename);
561 assert(cache_view->image->cache != (Cache) NULL);
562 id=GetOpenMPThreadId();
563 assert(id < (long) cache_view->number_threads);
564 pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
565 cache_view->nexus_info[id]);
566 return(pixels);
567}
568
569/*
570%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571% %
572% %
573% %
574% G e t C a c h e V i e w V i r t u a l I n d e x Q u e u e %
575% %
576% %
577% %
578%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
579%
580% GetCacheViewVirtualIndexQueue() returns the indexes associated with the
581% last call to GetCacheViewVirtualIndexQueue(). The indexes are virtual and
582% therefore cannot be updated.
583%
584% The format of the GetCacheViewVirtualIndexQueue() method is:
585%
586% const IndexPacket *GetCacheViewVirtualIndexQueue(
587% const CacheView *cache_view)
588%
589% A description of each parameter follows:
590%
591% o cache_view: the cache view.
592%
593*/
594MagickExport const IndexPacket *GetCacheViewVirtualIndexQueue(
595 const CacheView *cache_view)
596{
597 const IndexPacket
598 *indexes;
599
600 long
601 id;
602
603 assert(cache_view != (const CacheView *) NULL);
604 assert(cache_view->signature == MagickSignature);
605 if (cache_view->debug != MagickFalse)
606 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
607 cache_view->image->filename);
608 assert(cache_view->image->cache != (Cache) NULL);
609 id=GetOpenMPThreadId();
610 assert(id < (long) cache_view->number_threads);
611 indexes=GetVirtualIndexesFromNexus(cache_view->image->cache,
612 cache_view->nexus_info[id]);
613 return(indexes);
614}
615
616/*
617%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618% %
619% %
620% %
621% 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 %
622% %
623% %
624% %
625%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
626%
627% GetCacheViewVirtualPixelQueue() returns the the pixels associated with
628% the last call to GetCacheViewVirtualPixels(). The pixels are virtual
629% and therefore cannot be updated.
630%
631% The format of the GetCacheViewVirtualPixelQueue() method is:
632%
633% const PixelPacket *GetCacheViewVirtualPixelQueue(
634% const CacheView *cache_view)
635%
636% A description of each parameter follows:
637%
638% o cache_view: the cache view.
639%
640*/
641MagickExport const PixelPacket *GetCacheViewVirtualPixelQueue(
642 const CacheView *cache_view)
643{
644 const PixelPacket
645 *pixels;
646
647 long
648 id;
649
650 assert(cache_view != (const CacheView *) NULL);
651 assert(cache_view->signature == MagickSignature);
652 if (cache_view->debug != MagickFalse)
653 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
654 cache_view->image->filename);
655 assert(cache_view->image->cache != (Cache) NULL);
656 id=GetOpenMPThreadId();
657 assert(id < (long) cache_view->number_threads);
658 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
659 cache_view->nexus_info[id]);
660 return(pixels);
661}
662
663/*
664%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
665% %
666% %
667% %
668% 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 %
669% %
670% %
671% %
672%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673%
674% GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
675% disk pixel cache as defined by the geometry parameters. A pointer to the
676% pixels is returned if the pixels are transferred, otherwise a NULL is
677% returned.
678%
679% The format of the GetCacheViewVirtualPixels method is:
680%
681% const PixelPacket *GetCacheViewVirtualPixels(
682% const CacheView *cache_view,const long x,const long y,
683% const unsigned long columns,const unsigned long rows,
684% ExceptionInfo *exception)
685%
686% A description of each parameter follows:
687%
688% o cache_view: the cache view.
689%
690% o x,y,columns,rows: These values define the perimeter of a region of
691% pixels.
692%
693% o exception: return any errors or warnings in this structure.
694%
695*/
696MagickExport const PixelPacket *GetCacheViewVirtualPixels(
697 const CacheView *cache_view,const long x,const long y,
698 const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
699{
700 const PixelPacket
701 *pixels;
702
703 long
704 id;
705
706 assert(cache_view != (CacheView *) NULL);
707 assert(cache_view->signature == MagickSignature);
708 if (cache_view->debug != MagickFalse)
709 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
710 cache_view->image->filename);
711 id=GetOpenMPThreadId();
712 assert(id < (long) cache_view->number_threads);
713 pixels=GetVirtualPixelsFromNexus(cache_view->image,
714 cache_view->virtual_pixel_method,x,y,columns,rows,
715 cache_view->nexus_info[id],exception);
716 return(pixels);
717}
718
719/*
720%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721% %
722% %
723% %
724% 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 %
725% %
726% %
727% %
728%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
729%
730% GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
731% location. The image background color is returned if an error occurs. If
732% you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
733%
734% The format of the GetOneCacheViewVirtualPixel method is:
735%
736% MagickBooleanType GetOneCacheViewVirtualPixel(
737% const CacheView *cache_view,const long x,const long y,
738% PixelPacket *pixel,ExceptionInfo *exception)
739%
740% A description of each parameter follows:
741%
742% o cache_view: the cache view.
743%
744% o x,y: These values define the offset of the pixel.
745%
746% o pixel: return a pixel at the specified (x,y) location.
747%
748% o exception: return any errors or warnings in this structure.
749%
750*/
751MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
752 const CacheView *cache_view,const long x,const long y,PixelPacket *pixel,
753 ExceptionInfo *exception)
754{
755 const PixelPacket
756 *pixels;
757
758 long
759 id;
760
761 assert(cache_view != (CacheView *) NULL);
762 assert(cache_view->signature == MagickSignature);
763 if (cache_view->debug != MagickFalse)
764 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
765 cache_view->image->filename);
766 *pixel=cache_view->image->background_color;
767 id=GetOpenMPThreadId();
768 assert(id < (long) cache_view->number_threads);
769 pixels=GetVirtualPixelsFromNexus(cache_view->image,
770 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
771 exception);
772 if (pixels == (const PixelPacket *) NULL)
773 return(MagickFalse);
774 *pixel=(*pixels);
775 return(MagickTrue);
776}
777
778/*
779%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
780% %
781% %
782% %
783% 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 %
784% %
785% %
786% %
787%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
788%
789% GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
790% the specified (x,y) location. The image background color is returned if an
791% error occurs. If you plan to modify the pixel, use
792% GetOneCacheViewAuthenticPixel() instead.
793%
794% The format of the GetOneCacheViewVirtualPixel method is:
795%
796% MagickBooleanType GetOneCacheViewVirtualMethodPixel(
797% const CacheView *cache_view,
798% const VirtualPixelMethod virtual_pixel_method,const long x,
799% const long y,PixelPacket *pixel,ExceptionInfo *exception)
800%
801% A description of each parameter follows:
802%
803% o cache_view: the cache view.
804%
805% o virtual_pixel_method: the virtual pixel method.
806%
807% o x,y: These values define the offset of the pixel.
808%
809% o pixel: return a pixel at the specified (x,y) location.
810%
811% o exception: return any errors or warnings in this structure.
812%
813*/
814MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
815 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
816 const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
817{
818 const PixelPacket
819 *pixels;
820
821 long
822 id;
823
824 assert(cache_view != (CacheView *) NULL);
825 assert(cache_view->signature == MagickSignature);
826 if (cache_view->debug != MagickFalse)
827 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
828 cache_view->image->filename);
829 *pixel=cache_view->image->background_color;
830 id=GetOpenMPThreadId();
831 assert(id < (long) cache_view->number_threads);
832 pixels=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,
833 1,cache_view->nexus_info[id],exception);
834 if (pixels == (const PixelPacket *) NULL)
835 return(MagickFalse);
836 *pixel=(*pixels);
837 return(MagickTrue);
838}
839
840/*
841%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
842% %
843% %
844% %
845% 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 %
846% %
847% %
848% %
849%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
850%
851% QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
852% disk pixel cache as defined by the geometry parameters. A pointer to the
853% pixels is returned if the pixels are transferred, otherwise a NULL is
854% returned.
855%
856% The format of the QueueCacheViewAuthenticPixels method is:
857%
858% PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
859% const long x,const long y,const unsigned long columns,
860% const unsigned long rows,ExceptionInfo *exception)
861%
862% A description of each parameter follows:
863%
864% o cache_view: the cache view.
865%
866% o x,y,columns,rows: These values define the perimeter of a region of
867% pixels.
868%
869% o exception: return any errors or warnings in this structure.
870%
871*/
872MagickExport PixelPacket *QueueCacheViewAuthenticPixels(CacheView *cache_view,
873 const long x,const long y,const unsigned long columns,
874 const unsigned long rows,ExceptionInfo *exception)
875{
876 Cache
877 cache;
878
879 long
880 id;
881
882 PixelPacket
883 *pixels;
884
885 assert(cache_view != (CacheView *) NULL);
886 assert(cache_view->signature == MagickSignature);
887 if (cache_view->debug != MagickFalse)
888 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
889 cache_view->image->filename);
890 cache=GetImagePixelCache(cache_view->image,MagickFalse,exception);
891 if (cache == (Cache) NULL)
892 return((PixelPacket *) NULL);
893 id=GetOpenMPThreadId();
894 assert(id < (long) cache_view->number_threads);
895 pixels=QueueAuthenticNexus(cache_view->image,x,y,columns,rows,
896 cache_view->nexus_info[id],exception);
897 return(pixels);
898}
899
900/*
901%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
902% %
903% %
904% %
905% S e t C a c h e V i e w S t o r a g e C l a s s %
906% %
907% %
908% %
909%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
910%
911% SetCacheViewStorageClass() sets the image storage class associated with
912% the specified view.
913%
914% The format of the SetCacheViewStorageClass method is:
915%
916% MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
917% const ClassType storage_class)
918%
919% A description of each parameter follows:
920%
921% o cache_view: the cache view.
922%
923% o storage_class: the image storage class: PseudoClass or DirectClass.
924%
925*/
926MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
927 const ClassType storage_class)
928{
929 assert(cache_view != (CacheView *) NULL);
930 assert(cache_view->signature == MagickSignature);
931 if (cache_view->debug != MagickFalse)
932 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
933 cache_view->image->filename);
934 return(SetImageStorageClass(cache_view->image,storage_class));
935}
936
937/*
938%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
939% %
940% %
941% %
942% 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 %
943% %
944% %
945% %
946%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
947%
948% SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
949% with the specified cache view.
950%
951% The format of the SetCacheViewVirtualPixelMethod method is:
952%
953% MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
954% const VirtualPixelMethod virtual_pixel_method)
955%
956% A description of each parameter follows:
957%
958% o cache_view: the cache view.
959%
960% o virtual_pixel_method: the virtual pixel method.
961%
962*/
963MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
964 CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
965{
966 assert(cache_view != (CacheView *) NULL);
967 assert(cache_view->signature == MagickSignature);
968 if (cache_view->debug != MagickFalse)
969 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
970 cache_view->image->filename);
971 cache_view->virtual_pixel_method=virtual_pixel_method;
972 return(MagickTrue);
973}
974
975/*
976%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
977% %
978% %
979% %
980% 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 %
981% %
982% %
983% %
984%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
985%
986% SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
987% or disk cache. It returns MagickTrue if the pixel region is flushed,
988% otherwise MagickFalse.
989%
990% The format of the SyncCacheViewAuthenticPixels method is:
991%
992% MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
993% ExceptionInfo *exception)
994%
995% A description of each parameter follows:
996%
997% o cache_view: the cache view.
998%
999% o exception: return any errors or warnings in this structure.
1000%
1001*/
1002MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
1003 CacheView *cache_view,ExceptionInfo *exception)
1004{
1005 long
1006 id;
1007
1008 MagickBooleanType
1009 status;
1010
1011 assert(cache_view != (CacheView *) NULL);
1012 assert(cache_view->signature == MagickSignature);
1013 if (cache_view->debug != MagickFalse)
1014 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1015 cache_view->image->filename);
1016 id=GetOpenMPThreadId();
1017 assert(id < (long) cache_view->number_threads);
1018 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1019 cache_view->nexus_info[id],exception);
1020 return(status);
1021}