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