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