blob: 4a7fd294138268ae158f5a6f2c3d2a5b2d79c054 [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 %
cristyde984cd2013-12-01 14:49:27 +000022% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000023% February 2000 %
24% %
25% %
cristyb56bb242014-11-25 17:12:48 +000026% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000027% 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*/
cristy4c08aed2011-07-01 19:47:50 +000049#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"
cristye42639a2012-08-23 01:53:24 +000054#include "MagickCore/memory-private.h"
cristy4c08aed2011-07-01 19:47:50 +000055#include "MagickCore/exception.h"
56#include "MagickCore/exception-private.h"
57#include "MagickCore/pixel-accessor.h"
cristyac245f82012-05-05 17:13:57 +000058#include "MagickCore/resource_.h"
cristy4c08aed2011-07-01 19:47:50 +000059#include "MagickCore/string_.h"
60#include "MagickCore/thread-private.h"
cristy3ed852e2009-09-05 21:47:34 +000061
62/*
63 Typedef declarations.
64*/
65struct _CacheView
66{
67 Image
68 *image;
69
70 VirtualPixelMethod
71 virtual_pixel_method;
72
cristybb503372010-05-27 20:51:26 +000073 size_t
cristy3ed852e2009-09-05 21:47:34 +000074 number_threads;
75
76 NexusInfo
77 **nexus_info;
78
79 MagickBooleanType
80 debug;
81
cristybb503372010-05-27 20:51:26 +000082 size_t
cristy3ed852e2009-09-05 21:47:34 +000083 signature;
84};
85
86/*
87%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88% %
89% %
90% %
cristydb070952012-04-20 14:33:00 +000091% 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 %
cristy3ed852e2009-09-05 21:47:34 +000092% %
93% %
94% %
95%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96%
cristydb070952012-04-20 14:33:00 +000097% AcquireAuthenticCacheView() acquires an authentic view into the pixel cache.
cristy46ff2672012-12-14 15:32:26 +000098% It always succeeds but may return a warning or informational exception.
cristy3ed852e2009-09-05 21:47:34 +000099%
cristydb070952012-04-20 14:33:00 +0000100% The format of the AcquireAuthenticCacheView method is:
cristy3ed852e2009-09-05 21:47:34 +0000101%
cristy46ff2672012-12-14 15:32:26 +0000102% CacheView *AcquireAuthenticCacheView(const Image *image,
103% ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000104%
105% A description of each parameter follows:
106%
107% o image: the image.
108%
cristydb070952012-04-20 14:33:00 +0000109% o exception: return any errors or warnings in this structure.
110%
cristy3ed852e2009-09-05 21:47:34 +0000111*/
cristy46ff2672012-12-14 15:32:26 +0000112MagickExport CacheView *AcquireAuthenticCacheView(const Image *image,
113 ExceptionInfo *exception)
cristydb070952012-04-20 14:33:00 +0000114{
115 CacheView
dirk05d2ff72015-11-18 23:13:43 +0100116 *magick_restrict cache_view;
cristydb070952012-04-20 14:33:00 +0000117
cristy46ff2672012-12-14 15:32:26 +0000118 cache_view=AcquireVirtualCacheView(image,exception);
cristyb7649102012-12-13 16:43:21 +0000119 (void) SyncImagePixelCache(cache_view->image,exception);
cristydb070952012-04-20 14:33:00 +0000120 return(cache_view);
121}
122
123/*
124%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125% %
126% %
127% %
128% A c q u i r e V i r t u a l C a c h e V i e w %
129% %
130% %
131% %
132%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133%
134% AcquireVirtualCacheView() acquires a virtual view into the pixel cache,
135% using the VirtualPixelMethod that is defined within the given image itself.
cristy46ff2672012-12-14 15:32:26 +0000136% It always succeeds but may return a warning or informational exception.
cristydb070952012-04-20 14:33:00 +0000137%
138% The format of the AcquireVirtualCacheView method is:
139%
140% CacheView *AcquireVirtualCacheView(const Image *image,
141% ExceptionInfo *exception)
142%
143% A description of each parameter follows:
144%
145% o image: the image.
146%
cristy46ff2672012-12-14 15:32:26 +0000147% o exception: return any errors or warnings in this structure.
148%
cristydb070952012-04-20 14:33:00 +0000149*/
cristy46ff2672012-12-14 15:32:26 +0000150MagickExport CacheView *AcquireVirtualCacheView(const Image *image,
151 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000152{
153 CacheView
dirk05d2ff72015-11-18 23:13:43 +0100154 *magick_restrict cache_view;
cristy3ed852e2009-09-05 21:47:34 +0000155
156 assert(image != (Image *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000157 assert(image->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000158 if (image->debug != MagickFalse)
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
cristy46ff2672012-12-14 15:32:26 +0000160 (void) exception;
cristye42639a2012-08-23 01:53:24 +0000161 cache_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
162 sizeof(*cache_view)));
cristy3ed852e2009-09-05 21:47:34 +0000163 if (cache_view == (CacheView *) NULL)
164 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
165 (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
166 cache_view->image=ReferenceImage((Image *) image);
cristyd99b5a52012-10-27 23:07:47 +0000167 cache_view->number_threads=GetOpenMPMaximumThreads();
168 if (GetMagickResourceLimit(ThreadResource) > cache_view->number_threads)
169 cache_view->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
170 if (cache_view->number_threads == 0)
171 cache_view->number_threads=1;
cristy3ed852e2009-09-05 21:47:34 +0000172 cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
173 cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
174 cache_view->debug=IsEventLogging();
cristye1c94d92015-06-28 12:16:33 +0000175 cache_view->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000176 if (cache_view->nexus_info == (NexusInfo **) NULL)
177 ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
178 return(cache_view);
179}
180
181/*
182%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183% %
184% %
185% %
186% C l o n e C a c h e V i e w %
187% %
188% %
189% %
190%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
191%
192% CloneCacheView() makes an exact copy of the specified cache view.
193%
194% The format of the CloneCacheView method is:
195%
196% CacheView *CloneCacheView(const CacheView *cache_view)
197%
198% A description of each parameter follows:
199%
200% o cache_view: the cache view.
201%
202*/
203MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
204{
205 CacheView
dirk05d2ff72015-11-18 23:13:43 +0100206 *magick_restrict clone_view;
cristy3ed852e2009-09-05 21:47:34 +0000207
208 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000209 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000210 if (cache_view->debug != MagickFalse)
211 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
212 cache_view->image->filename);
cristye42639a2012-08-23 01:53:24 +0000213 clone_view=(CacheView *) MagickAssumeAligned(AcquireAlignedMemory(1,
214 sizeof(*clone_view)));
cristy3ed852e2009-09-05 21:47:34 +0000215 if (clone_view == (CacheView *) NULL)
216 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
217 (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
218 clone_view->image=ReferenceImage(cache_view->image);
219 clone_view->number_threads=cache_view->number_threads;
220 clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
221 clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
222 clone_view->debug=cache_view->debug;
cristye1c94d92015-06-28 12:16:33 +0000223 clone_view->signature=MagickCoreSignature;
cristy3ed852e2009-09-05 21:47:34 +0000224 return(clone_view);
225}
226
227/*
228%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229% %
230% %
231% %
232% D e s t r o y C a c h e V i e w %
233% %
234% %
235% %
236%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
237%
238% DestroyCacheView() destroys the specified view returned by a previous call
239% to AcquireCacheView().
240%
241% The format of the DestroyCacheView method is:
242%
243% CacheView *DestroyCacheView(CacheView *cache_view)
244%
245% A description of each parameter follows:
246%
247% o cache_view: the cache view.
248%
249*/
250MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
251{
252 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000253 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000254 if (cache_view->debug != MagickFalse)
255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
256 cache_view->image->filename);
257 if (cache_view->nexus_info != (NexusInfo **) NULL)
258 cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
259 cache_view->number_threads);
260 cache_view->image=DestroyImage(cache_view->image);
cristye1c94d92015-06-28 12:16:33 +0000261 cache_view->signature=(~MagickCoreSignature);
cristy27d53d62012-07-29 23:30:07 +0000262 cache_view=(CacheView *) RelinquishAlignedMemory(cache_view);
cristy3ed852e2009-09-05 21:47:34 +0000263 return(cache_view);
264}
265
266/*
267%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268% %
269% %
270% %
cristye7516622012-04-29 14:22:45 +0000271% 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 %
272% %
273% %
274% %
275%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276%
277% GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
278% cache as defined by the geometry parameters. A pointer to the pixels is
279% returned if the pixels are transferred, otherwise a NULL is returned.
280%
281% The format of the GetCacheViewAuthenticPixels method is:
282%
283% Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
284% const ssize_t x,const ssize_t y,const size_t columns,
285% const size_t rows,ExceptionInfo *exception)
286%
287% A description of each parameter follows:
288%
289% o cache_view: the cache view.
290%
291% o x,y,columns,rows: These values define the perimeter of a region of
292% pixels.
293%
294% o exception: return any errors or warnings in this structure.
295%
296*/
297MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
298 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
299 ExceptionInfo *exception)
300{
301 const int
302 id = GetOpenMPThreadId();
303
304 Quantum
dirk05d2ff72015-11-18 23:13:43 +0100305 *magick_restrict pixels;
cristye7516622012-04-29 14:22:45 +0000306
307 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000308 assert(cache_view->signature == MagickCoreSignature);
cristye7516622012-04-29 14:22:45 +0000309 assert(id < (int) cache_view->number_threads);
310 pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
311 cache_view->nexus_info[id],exception);
312 return(pixels);
313}
314
315/*
316%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317% %
318% %
319% %
320% G e t C a c h e V i e w A u t h e n t i c M e t a c o n t e n t %
321% %
322% %
323% %
324%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325%
326% GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
327% with the last call to SetCacheViewIndexes() or
328% GetCacheViewAuthenticMetacontent(). The meta-content are authentic and can
329% be updated.
330%
331% The format of the GetCacheViewAuthenticMetacontent() method is:
332%
333% void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
334%
335% A description of each parameter follows:
336%
337% o cache_view: the cache view.
338%
339*/
340MagickExport void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
341{
342 const int
343 id = GetOpenMPThreadId();
344
cristye7516622012-04-29 14:22:45 +0000345 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000346 assert(cache_view->signature == MagickCoreSignature);
cristye7516622012-04-29 14:22:45 +0000347 assert(cache_view->image->cache != (Cache) NULL);
348 assert(id < (int) cache_view->number_threads);
cristyffaf87e2013-04-30 17:09:30 +0000349 return(cache_view->nexus_info[id]->metacontent);
cristye7516622012-04-29 14:22:45 +0000350}
351
352/*
353%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354% %
355% %
356% %
357% G e t C a c h e V i e w A u t h e n t i c P i x e l Q u e u e %
358% %
359% %
360% %
361%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362%
363% GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
364% last call to QueueCacheViewAuthenticPixels() or
365% GetCacheViewAuthenticPixels(). The pixels are authentic and therefore can be
366% updated.
367%
368% The format of the GetCacheViewAuthenticPixelQueue() method is:
369%
370% Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
371%
372% A description of each parameter follows:
373%
374% o cache_view: the cache view.
375%
376*/
377MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
378{
379 const int
380 id = GetOpenMPThreadId();
381
cristye7516622012-04-29 14:22:45 +0000382 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000383 assert(cache_view->signature == MagickCoreSignature);
cristye7516622012-04-29 14:22:45 +0000384 assert(cache_view->image->cache != (Cache) NULL);
385 assert(id < (int) cache_view->number_threads);
cristyffaf87e2013-04-30 17:09:30 +0000386 return(cache_view->nexus_info[id]->pixels);
cristye7516622012-04-29 14:22:45 +0000387}
388
389/*
390%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391% %
392% %
393% %
cristy3ed852e2009-09-05 21:47:34 +0000394% G e t C a c h e V i e w C o l o r s p a c e %
395% %
396% %
397% %
398%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
399%
400% GetCacheViewColorspace() returns the image colorspace associated with the
401% specified view.
402%
403% The format of the GetCacheViewColorspace method is:
404%
405% ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
406%
407% A description of each parameter follows:
408%
409% o cache_view: the cache view.
410%
411*/
412MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
413{
414 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000415 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000416 if (cache_view->debug != MagickFalse)
417 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
418 cache_view->image->filename);
cristy0d267172011-04-25 20:13:48 +0000419 return(GetPixelCacheColorspace(cache_view->image->cache));
cristy3ed852e2009-09-05 21:47:34 +0000420}
421
422/*
423%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
424% %
425% %
426% %
cristy3ed852e2009-09-05 21:47:34 +0000427+ G e t C a c h e V i e w E x t e n t %
428% %
429% %
430% %
431%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
432%
433% GetCacheViewExtent() returns the extent of the pixels associated with the
434% last call to QueueCacheViewAuthenticPixels() or
435% GetCacheViewAuthenticPixels().
436%
437% The format of the GetCacheViewExtent() method is:
438%
439% MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
440%
441% A description of each parameter follows:
442%
443% o cache_view: the cache view.
444%
445*/
446MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
447{
cristy5c9e6f22010-09-17 17:31:01 +0000448 const int
449 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000450
cristy4c08aed2011-07-01 19:47:50 +0000451 MagickSizeType
452 extent;
453
cristy3ed852e2009-09-05 21:47:34 +0000454 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000455 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000456 if (cache_view->debug != MagickFalse)
457 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
458 cache_view->image->filename);
459 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000460 assert(id < (int) cache_view->number_threads);
cristy4c08aed2011-07-01 19:47:50 +0000461 extent=GetPixelCacheNexusExtent(cache_view->image->cache,
462 cache_view->nexus_info[id]);
463 return(extent);
cristy3ed852e2009-09-05 21:47:34 +0000464}
465
466/*
467%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
468% %
469% %
470% %
cristye7516622012-04-29 14:22:45 +0000471% G e t C a c h e V i e w I m a g e %
472% %
473% %
474% %
475%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
476%
477% GetCacheViewImage() returns the image associated with the specified view.
478%
479% The format of the GetCacheViewImage method is:
480%
481% const Image *GetCacheViewImage(const CacheView *cache_view)
482%
483% A description of each parameter follows:
484%
485% o cache_view: the cache view.
486%
487*/
488MagickExport const Image *GetCacheViewImage(const CacheView *cache_view)
489{
490 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000491 assert(cache_view->signature == MagickCoreSignature);
cristye7516622012-04-29 14:22:45 +0000492 if (cache_view->debug != MagickFalse)
493 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
494 cache_view->image->filename);
495 return(cache_view->image);
496}
497
498/*
499%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500% %
501% %
502% %
cristy3ed852e2009-09-05 21:47:34 +0000503% G e t C a c h e V i e w S t o r a g e C l a s s %
504% %
505% %
506% %
507%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
508%
cristye7516622012-04-29 14:22:45 +0000509% GetCacheViewStorageClass() returns the image storage class associated with
cristy3ed852e2009-09-05 21:47:34 +0000510% the specified view.
511%
512% The format of the GetCacheViewStorageClass method is:
513%
514% ClassType GetCacheViewStorageClass(const CacheView *cache_view)
515%
516% A description of each parameter follows:
517%
518% o cache_view: the cache view.
519%
520*/
521MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
522{
523 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000524 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000525 if (cache_view->debug != MagickFalse)
526 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
527 cache_view->image->filename);
cristy0d267172011-04-25 20:13:48 +0000528 return(GetPixelCacheStorageClass(cache_view->image->cache));
cristy3ed852e2009-09-05 21:47:34 +0000529}
530
531/*
532%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
533% %
534% %
535% %
cristy4c08aed2011-07-01 19:47:50 +0000536% 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 %
cristy3ed852e2009-09-05 21:47:34 +0000537% %
538% %
539% %
540%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
541%
cristy4c08aed2011-07-01 19:47:50 +0000542% GetCacheViewVirtualMetacontent() returns the meta-content corresponding
543% with the last call to GetCacheViewVirtualMetacontent(). The meta-content
544% is virtual and therefore cannot be updated.
cristy3ed852e2009-09-05 21:47:34 +0000545%
cristy4c08aed2011-07-01 19:47:50 +0000546% The format of the GetCacheViewVirtualMetacontent() method is:
cristy3ed852e2009-09-05 21:47:34 +0000547%
cristy4c08aed2011-07-01 19:47:50 +0000548% const void *GetCacheViewVirtualMetacontent(
cristy3ed852e2009-09-05 21:47:34 +0000549% const CacheView *cache_view)
550%
551% A description of each parameter follows:
552%
553% o cache_view: the cache view.
554%
555*/
cristy4c08aed2011-07-01 19:47:50 +0000556MagickExport const void *GetCacheViewVirtualMetacontent(
cristy3ed852e2009-09-05 21:47:34 +0000557 const CacheView *cache_view)
558{
cristy5c9e6f22010-09-17 17:31:01 +0000559 const int
560 id = GetOpenMPThreadId();
cristy3ed852e2009-09-05 21:47:34 +0000561
cristy4c08aed2011-07-01 19:47:50 +0000562 const void
dirk05d2ff72015-11-18 23:13:43 +0100563 *magick_restrict metacontent;
cristy4c08aed2011-07-01 19:47:50 +0000564
cristy3ed852e2009-09-05 21:47:34 +0000565 assert(cache_view != (const CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000566 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000567 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000568 assert(id < (int) cache_view->number_threads);
cristy4c08aed2011-07-01 19:47:50 +0000569 metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
570 cache_view->nexus_info[id]);
571 return(metacontent);
cristy3ed852e2009-09-05 21:47:34 +0000572}
573
574/*
575%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
576% %
577% %
578% %
579% G e t C a c h e V i e w V i r t u a l P i x e l Q u e u e %
580% %
581% %
582% %
583%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584%
585% GetCacheViewVirtualPixelQueue() returns the the pixels associated with
586% the last call to GetCacheViewVirtualPixels(). The pixels are virtual
587% and therefore cannot be updated.
588%
589% The format of the GetCacheViewVirtualPixelQueue() method is:
590%
cristy4c08aed2011-07-01 19:47:50 +0000591% const Quantum *GetCacheViewVirtualPixelQueue(
cristy3ed852e2009-09-05 21:47:34 +0000592% const CacheView *cache_view)
593%
594% A description of each parameter follows:
595%
596% o cache_view: the cache view.
597%
598*/
cristy4c08aed2011-07-01 19:47:50 +0000599MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
cristy3ed852e2009-09-05 21:47:34 +0000600 const CacheView *cache_view)
601{
cristy5c9e6f22010-09-17 17:31:01 +0000602 const int
603 id = GetOpenMPThreadId();
604
cristy4c08aed2011-07-01 19:47:50 +0000605 const Quantum
dirk05d2ff72015-11-18 23:13:43 +0100606 *magick_restrict pixels;
cristy4c08aed2011-07-01 19:47:50 +0000607
cristy3ed852e2009-09-05 21:47:34 +0000608 assert(cache_view != (const CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000609 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000610 assert(cache_view->image->cache != (Cache) NULL);
cristy4205a3c2010-09-12 20:19:59 +0000611 assert(id < (int) cache_view->number_threads);
cristy4c08aed2011-07-01 19:47:50 +0000612 pixels=GetVirtualPixelsNexus(cache_view->image->cache,
613 cache_view->nexus_info[id]);
614 return(pixels);
cristy3ed852e2009-09-05 21:47:34 +0000615}
616
617/*
618%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619% %
620% %
621% %
622% G e t C a c h e V i e w V i r t u a l P i x e l s %
623% %
624% %
625% %
626%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627%
628% GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
629% disk pixel cache as defined by the geometry parameters. A pointer to the
630% pixels is returned if the pixels are transferred, otherwise a NULL is
631% returned.
632%
633% The format of the GetCacheViewVirtualPixels method is:
634%
cristy4c08aed2011-07-01 19:47:50 +0000635% const Quantum *GetCacheViewVirtualPixels(
cristybb503372010-05-27 20:51:26 +0000636% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristye076a6e2010-08-15 19:59:43 +0000637% const size_t columns,const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000638%
639% A description of each parameter follows:
640%
641% o cache_view: the cache view.
642%
643% o x,y,columns,rows: These values define the perimeter of a region of
644% pixels.
645%
646% o exception: return any errors or warnings in this structure.
647%
648*/
cristy4c08aed2011-07-01 19:47:50 +0000649MagickExport const Quantum *GetCacheViewVirtualPixels(
cristybb503372010-05-27 20:51:26 +0000650 const CacheView *cache_view,const ssize_t x,const ssize_t y,
651 const size_t columns,const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000652{
cristy5c9e6f22010-09-17 17:31:01 +0000653 const int
654 id = GetOpenMPThreadId();
655
cristy4c08aed2011-07-01 19:47:50 +0000656 const Quantum
dirk05d2ff72015-11-18 23:13:43 +0100657 *magick_restrict pixels;
cristy4c08aed2011-07-01 19:47:50 +0000658
cristy3ed852e2009-09-05 21:47:34 +0000659 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000660 assert(cache_view->signature == MagickCoreSignature);
cristy4205a3c2010-09-12 20:19:59 +0000661 assert(id < (int) cache_view->number_threads);
cristy4c08aed2011-07-01 19:47:50 +0000662 pixels=GetVirtualPixelsFromNexus(cache_view->image,
cristy3ed852e2009-09-05 21:47:34 +0000663 cache_view->virtual_pixel_method,x,y,columns,rows,
cristy4c08aed2011-07-01 19:47:50 +0000664 cache_view->nexus_info[id],exception);
665 return(pixels);
666}
667
668/*
669%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
670% %
671% %
672% %
673% G e t O n e C a c h e V i e w A u t h e n t i c P i x e l %
674% %
675% %
676% %
677%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
678%
679% GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
680% location. The image background color is returned if an error occurs.
681%
682% The format of the GetOneCacheViewAuthenticPixel method is:
683%
684% MagickBooleaNType GetOneCacheViewAuthenticPixel(
685% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristy2ed42f62011-10-02 19:49:57 +0000686% Quantum *pixel,ExceptionInfo *exception)
cristy4c08aed2011-07-01 19:47:50 +0000687%
688% A description of each parameter follows:
689%
690% o cache_view: the cache view.
691%
692% o x,y: These values define the offset of the pixel.
693%
694% o pixel: return a pixel at the specified (x,y) location.
695%
696% o exception: return any errors or warnings in this structure.
697%
698*/
699MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
cristy2ed42f62011-10-02 19:49:57 +0000700 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
701 ExceptionInfo *exception)
cristy4c08aed2011-07-01 19:47:50 +0000702{
703 const int
704 id = GetOpenMPThreadId();
705
706 Quantum
dirk05d2ff72015-11-18 23:13:43 +0100707 *magick_restrict q;
cristy4c08aed2011-07-01 19:47:50 +0000708
cristy2ed42f62011-10-02 19:49:57 +0000709 register ssize_t
710 i;
711
cristy4c08aed2011-07-01 19:47:50 +0000712 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000713 assert(cache_view->signature == MagickCoreSignature);
cristy4c08aed2011-07-01 19:47:50 +0000714 assert(id < (int) cache_view->number_threads);
cristy2ed42f62011-10-02 19:49:57 +0000715 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
cristy584cbf82013-04-19 12:21:58 +0000716 q=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
cristy4c08aed2011-07-01 19:47:50 +0000717 cache_view->nexus_info[id],exception);
cristy584cbf82013-04-19 12:21:58 +0000718 if (q == (const Quantum *) NULL)
cristy2ed42f62011-10-02 19:49:57 +0000719 {
cristyd09f8802012-02-04 16:44:10 +0000720 PixelInfo
721 background_color;
722
723 background_color=cache_view->image->background_color;
724 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
725 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
726 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
727 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
728 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
cristy2ed42f62011-10-02 19:49:57 +0000729 return(MagickFalse);
730 }
731 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
732 {
cristy5a23c552013-02-13 14:34:28 +0000733 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
cristy584cbf82013-04-19 12:21:58 +0000734 pixel[channel]=q[i];
cristy2ed42f62011-10-02 19:49:57 +0000735 }
cristy4c08aed2011-07-01 19:47:50 +0000736 return(MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +0000737}
738
739/*
740%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741% %
742% %
743% %
744% G e t O n e C a c h e V i e w V i r t u a l P i x e l %
745% %
746% %
747% %
748%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
749%
750% GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
751% location. The image background color is returned if an error occurs. If
752% you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
753%
754% The format of the GetOneCacheViewVirtualPixel method is:
755%
756% MagickBooleanType GetOneCacheViewVirtualPixel(
cristybb503372010-05-27 20:51:26 +0000757% const CacheView *cache_view,const ssize_t x,const ssize_t y,
cristy2ed42f62011-10-02 19:49:57 +0000758% Quantum *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000759%
760% A description of each parameter follows:
761%
762% o cache_view: the cache view.
763%
764% o x,y: These values define the offset of the pixel.
765%
766% o pixel: return a pixel at the specified (x,y) location.
767%
768% o exception: return any errors or warnings in this structure.
769%
770*/
771MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
cristy2ed42f62011-10-02 19:49:57 +0000772 const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
773 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000774{
cristy5c9e6f22010-09-17 17:31:01 +0000775 const int
776 id = GetOpenMPThreadId();
777
cristyf05d4942012-03-17 16:26:09 +0000778 register const Quantum
dirk05d2ff72015-11-18 23:13:43 +0100779 *magick_restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000780
cristy2ed42f62011-10-02 19:49:57 +0000781 register ssize_t
782 i;
783
cristy3ed852e2009-09-05 21:47:34 +0000784 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000785 assert(cache_view->signature == MagickCoreSignature);
cristy4205a3c2010-09-12 20:19:59 +0000786 assert(id < (int) cache_view->number_threads);
cristy2ed42f62011-10-02 19:49:57 +0000787 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
cristy4c08aed2011-07-01 19:47:50 +0000788 p=GetVirtualPixelsFromNexus(cache_view->image,
cristy3ed852e2009-09-05 21:47:34 +0000789 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
790 exception);
cristy4c08aed2011-07-01 19:47:50 +0000791 if (p == (const Quantum *) NULL)
cristy2ed42f62011-10-02 19:49:57 +0000792 {
cristyd09f8802012-02-04 16:44:10 +0000793 PixelInfo
794 background_color;
795
796 background_color=cache_view->image->background_color;
797 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
798 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
799 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
800 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
801 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
cristy2ed42f62011-10-02 19:49:57 +0000802 return(MagickFalse);
803 }
804 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
805 {
cristy5a23c552013-02-13 14:34:28 +0000806 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
cristy2ed42f62011-10-02 19:49:57 +0000807 pixel[channel]=p[i];
808 }
cristy3ed852e2009-09-05 21:47:34 +0000809 return(MagickTrue);
810}
811
812/*
813%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
814% %
815% %
816% %
cristyf05d4942012-03-17 16:26:09 +0000817% 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 %
818% %
819% %
820% %
821%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
822%
823% GetOneCacheViewVirtualPixelInfo() returns a single pixel at the specified
824% (x,y) location. The image background color is returned if an error occurs.
825% If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
826%
827% The format of the GetOneCacheViewVirtualPixelInfo method is:
828%
829% MagickBooleanType GetOneCacheViewVirtualPixelInfo(
830% const CacheView *cache_view,const ssize_t x,const ssize_t y,
831% PixelInfo *pixel,ExceptionInfo *exception)
832%
833% A description of each parameter follows:
834%
835% o cache_view: the cache view.
836%
837% o x,y: These values define the offset of the pixel.
838%
839% o pixel: return a pixel at the specified (x,y) location.
840%
841% o exception: return any errors or warnings in this structure.
842%
843*/
844MagickExport MagickBooleanType GetOneCacheViewVirtualPixelInfo(
845 const CacheView *cache_view,const ssize_t x,const ssize_t y,PixelInfo *pixel,
846 ExceptionInfo *exception)
847{
848 const int
849 id = GetOpenMPThreadId();
850
851 register const Quantum
dirk05d2ff72015-11-18 23:13:43 +0100852 *magick_restrict p;
cristyf05d4942012-03-17 16:26:09 +0000853
854 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000855 assert(cache_view->signature == MagickCoreSignature);
cristyf05d4942012-03-17 16:26:09 +0000856 assert(id < (int) cache_view->number_threads);
cristyf82cff82012-04-16 16:54:17 +0000857 GetPixelInfo(cache_view->image,pixel);
cristyf05d4942012-03-17 16:26:09 +0000858 p=GetVirtualPixelsFromNexus(cache_view->image,
859 cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
860 exception);
cristyf05d4942012-03-17 16:26:09 +0000861 if (p == (const Quantum *) NULL)
862 return(MagickFalse);
863 GetPixelInfoPixel(cache_view->image,p,pixel);
864 return(MagickTrue);
865}
866
867/*
868%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869% %
870% %
871% %
cristy3ed852e2009-09-05 21:47:34 +0000872% 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 %
873% %
874% %
875% %
876%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
877%
878% GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
879% the specified (x,y) location. The image background color is returned if an
880% error occurs. If you plan to modify the pixel, use
881% GetOneCacheViewAuthenticPixel() instead.
882%
883% The format of the GetOneCacheViewVirtualPixel method is:
884%
885% MagickBooleanType GetOneCacheViewVirtualMethodPixel(
886% const CacheView *cache_view,
cristybb503372010-05-27 20:51:26 +0000887% const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
cristy2ed42f62011-10-02 19:49:57 +0000888% const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000889%
890% A description of each parameter follows:
891%
892% o cache_view: the cache view.
893%
894% o virtual_pixel_method: the virtual pixel method.
895%
896% o x,y: These values define the offset of the pixel.
897%
898% o pixel: return a pixel at the specified (x,y) location.
899%
900% o exception: return any errors or warnings in this structure.
901%
902*/
903MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
904 const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
cristy2ed42f62011-10-02 19:49:57 +0000905 const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000906{
cristy5c9e6f22010-09-17 17:31:01 +0000907 const int
908 id = GetOpenMPThreadId();
909
cristy4c08aed2011-07-01 19:47:50 +0000910 const Quantum
dirk05d2ff72015-11-18 23:13:43 +0100911 *magick_restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000912
cristy2ed42f62011-10-02 19:49:57 +0000913 register ssize_t
914 i;
915
cristy3ed852e2009-09-05 21:47:34 +0000916 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000917 assert(cache_view->signature == MagickCoreSignature);
cristy4205a3c2010-09-12 20:19:59 +0000918 assert(id < (int) cache_view->number_threads);
cristy2ed42f62011-10-02 19:49:57 +0000919 (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
cristy4c08aed2011-07-01 19:47:50 +0000920 p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
921 cache_view->nexus_info[id],exception);
922 if (p == (const Quantum *) NULL)
cristy2ed42f62011-10-02 19:49:57 +0000923 {
cristyd09f8802012-02-04 16:44:10 +0000924 PixelInfo
925 background_color;
926
927 background_color=cache_view->image->background_color;
928 pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
929 pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
930 pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
931 pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
932 pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
cristy2ed42f62011-10-02 19:49:57 +0000933 return(MagickFalse);
934 }
935 for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
936 {
cristy5a23c552013-02-13 14:34:28 +0000937 PixelChannel channel=GetPixelChannelChannel(cache_view->image,i);
cristy2ed42f62011-10-02 19:49:57 +0000938 pixel[channel]=p[i];
939 }
cristy3ed852e2009-09-05 21:47:34 +0000940 return(MagickTrue);
941}
942
943/*
944%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
945% %
946% %
947% %
948% Q u e u e C a c h e V i e w A u t h e n t i c P i x e l s %
949% %
950% %
951% %
952%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953%
954% QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
955% disk pixel cache as defined by the geometry parameters. A pointer to the
956% pixels is returned if the pixels are transferred, otherwise a NULL is
957% returned.
958%
959% The format of the QueueCacheViewAuthenticPixels method is:
960%
cristy4c08aed2011-07-01 19:47:50 +0000961% Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
cristybb503372010-05-27 20:51:26 +0000962% const ssize_t x,const ssize_t y,const size_t columns,
963% const size_t rows,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000964%
965% A description of each parameter follows:
966%
967% o cache_view: the cache view.
968%
969% o x,y,columns,rows: These values define the perimeter of a region of
970% pixels.
971%
972% o exception: return any errors or warnings in this structure.
973%
974*/
cristy4c08aed2011-07-01 19:47:50 +0000975MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
cristy30097232010-07-01 02:16:30 +0000976 const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
977 ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000978{
cristy5c9e6f22010-09-17 17:31:01 +0000979 const int
980 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +0000981
cristy4c08aed2011-07-01 19:47:50 +0000982 Quantum
dirk05d2ff72015-11-18 23:13:43 +0100983 *magick_restrict pixels;
cristy4c08aed2011-07-01 19:47:50 +0000984
cristy3ed852e2009-09-05 21:47:34 +0000985 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000986 assert(cache_view->signature == MagickCoreSignature);
cristy4205a3c2010-09-12 20:19:59 +0000987 assert(id < (int) cache_view->number_threads);
cristyc11dace2012-01-24 16:39:46 +0000988 pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
989 MagickFalse,cache_view->nexus_info[id],exception);
cristy4c08aed2011-07-01 19:47:50 +0000990 return(pixels);
cristy3ed852e2009-09-05 21:47:34 +0000991}
992
993/*
994%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
995% %
996% %
997% %
998% S e t C a c h e V i e w S t o r a g e C l a s s %
999% %
1000% %
1001% %
1002%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1003%
1004% SetCacheViewStorageClass() sets the image storage class associated with
1005% the specified view.
1006%
1007% The format of the SetCacheViewStorageClass method is:
1008%
1009% MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
cristyc82a27b2011-10-21 01:07:16 +00001010% const ClassType storage_class,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001011%
1012% A description of each parameter follows:
1013%
1014% o cache_view: the cache view.
1015%
1016% o storage_class: the image storage class: PseudoClass or DirectClass.
1017%
cristyc82a27b2011-10-21 01:07:16 +00001018% o exception: return any errors or warnings in this structure.
1019%
cristy3ed852e2009-09-05 21:47:34 +00001020*/
1021MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
cristyc82a27b2011-10-21 01:07:16 +00001022 const ClassType storage_class,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001023{
1024 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +00001025 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +00001026 if (cache_view->debug != MagickFalse)
1027 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1028 cache_view->image->filename);
cristyc82a27b2011-10-21 01:07:16 +00001029 return(SetImageStorageClass(cache_view->image,storage_class,exception));
cristy3ed852e2009-09-05 21:47:34 +00001030}
1031
1032/*
1033%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1034% %
1035% %
1036% %
1037% S e t C a c h e V i e w V i r t u a l P i x e l M e t h o d %
1038% %
1039% %
1040% %
1041%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1042%
1043% SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
1044% with the specified cache view.
1045%
1046% The format of the SetCacheViewVirtualPixelMethod method is:
1047%
1048% MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
1049% const VirtualPixelMethod virtual_pixel_method)
1050%
1051% A description of each parameter follows:
1052%
1053% o cache_view: the cache view.
1054%
1055% o virtual_pixel_method: the virtual pixel method.
1056%
1057*/
1058MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
dirk05d2ff72015-11-18 23:13:43 +01001059 CacheView *magick_restrict cache_view,
1060 const VirtualPixelMethod virtual_pixel_method)
cristy3ed852e2009-09-05 21:47:34 +00001061{
1062 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +00001063 assert(cache_view->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +00001064 if (cache_view->debug != MagickFalse)
1065 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1066 cache_view->image->filename);
1067 cache_view->virtual_pixel_method=virtual_pixel_method;
1068 return(MagickTrue);
1069}
1070
1071/*
1072%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1073% %
1074% %
1075% %
1076% 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 %
1077% %
1078% %
1079% %
1080%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1081%
1082% SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
1083% or disk cache. It returns MagickTrue if the pixel region is flushed,
1084% otherwise MagickFalse.
1085%
1086% The format of the SyncCacheViewAuthenticPixels method is:
1087%
1088% MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
1089% ExceptionInfo *exception)
1090%
1091% A description of each parameter follows:
1092%
1093% o cache_view: the cache view.
1094%
1095% o exception: return any errors or warnings in this structure.
1096%
1097*/
1098MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
dirk05d2ff72015-11-18 23:13:43 +01001099 CacheView *magick_restrict cache_view,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +00001100{
cristy5c9e6f22010-09-17 17:31:01 +00001101 const int
1102 id = GetOpenMPThreadId();
cristy4205a3c2010-09-12 20:19:59 +00001103
cristy4c08aed2011-07-01 19:47:50 +00001104 MagickBooleanType
1105 status;
1106
cristy3ed852e2009-09-05 21:47:34 +00001107 assert(cache_view != (CacheView *) NULL);
cristye1c94d92015-06-28 12:16:33 +00001108 assert(cache_view->signature == MagickCoreSignature);
cristy4205a3c2010-09-12 20:19:59 +00001109 assert(id < (int) cache_view->number_threads);
cristy4c08aed2011-07-01 19:47:50 +00001110 status=SyncAuthenticPixelCacheNexus(cache_view->image,
1111 cache_view->nexus_info[id],exception);
1112 return(status);
cristy3ed852e2009-09-05 21:47:34 +00001113}