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