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