root / ImageMagick / branches / ImageMagick-6.3.5 / magick / cache-view.c
| Revision 8050, 29.8 kB (checked in by cristy, 14 months ago) |
|---|
| Line | |
|---|---|
| 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 | % ImageMagick Cache View Methods % |
| 20 | % % |
| 21 | % Software Design % |
| 22 | % John Cristy % |
| 23 | % February 2000 % |
| 24 | % % |
| 25 | % % |
| 26 | % Copyright 1999-2007 ImageMagick Studio LLC, a non-profit organization % |
| 27 | % dedicated to making software imaging solutions freely available. % |
| 28 | % % |
| 29 | % You may not use this file except in compliance with the License. You may % |
| 30 | % obtain a copy of the License at % |
| 31 | % % |
| 32 | % http://www.imagemagick.org/script/license.php % |
| 33 | % % |
| 34 | % Unless required by applicable law or agreed to in writing, software % |
| 35 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 36 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 37 | % See the License for the specific language governing permissions and % |
| 38 | % limitations under the License. % |
| 39 | % % |
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 | % |
| 42 | % |
| 43 | % |
| 44 | */ |
| 45 | |
| 46 | /* |
| 47 | Include declarations. |
| 48 | */ |
| 49 | #include "magick/studio.h" |
| 50 | #include "magick/cache.h" |
| 51 | #include "magick/cache-private.h" |
| 52 | #include "magick/cache-view.h" |
| 53 | #include "magick/memory_.h" |
| 54 | #include "magick/exception.h" |
| 55 | #include "magick/exception-private.h" |
| 56 | #include "magick/string_.h" |
| 57 | |
| 58 | /* |
| 59 | Typedef declarations. |
| 60 | */ |
| 61 | struct _ViewInfo |
| 62 | { |
| 63 | unsigned long |
| 64 | id; |
| 65 | |
| 66 | Image |
| 67 | *image; |
| 68 | |
| 69 | VirtualPixelMethod |
| 70 | virtual_pixel_method; |
| 71 | |
| 72 | MagickBooleanType |
| 73 | debug; |
| 74 | |
| 75 | unsigned long |
| 76 | signature; |
| 77 | }; |
| 78 | |
| 79 | /* |
| 80 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 81 | % % |
| 82 | % % |
| 83 | % % |
| 84 | % A c q u i r e C a c h e V i e w I n d e x e s % |
| 85 | % % |
| 86 | % % |
| 87 | % % |
| 88 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 89 | % |
| 90 | % AcquireCacheViewIndexes() returns the indexes associated with the specified |
| 91 | % view. |
| 92 | % |
| 93 | % The format of the AcquireCacheViewIndexes method is: |
| 94 | % |
| 95 | % const IndexPacket *AcquireCacheViewIndexes(const ViewInfo *view_info) |
| 96 | % |
| 97 | % A description of each parameter follows: |
| 98 | % |
| 99 | % o view_info: The address of a structure of type ViewInfo. |
| 100 | % |
| 101 | */ |
| 102 | MagickExport const IndexPacket *AcquireCacheViewIndexes( |
| 103 | const ViewInfo *view_info) |
| 104 | { |
| 105 | assert(view_info != (ViewInfo *) NULL); |
| 106 | assert(view_info->signature == MagickSignature); |
| 107 | assert(view_info->image != (Image *) NULL); |
| 108 | if (view_info->debug != MagickFalse) |
| 109 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 110 | view_info->image->filename); |
| 111 | return(AcquireNexusIndexes(view_info->image->cache,view_info->id)); |
| 112 | } |
| 113 | |
| 114 | /* |
| 115 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 116 | % % |
| 117 | % % |
| 118 | % % |
| 119 | % A c q u i r e C a c h e V i e w P i x e l s % |
| 120 | % % |
| 121 | % % |
| 122 | % % |
| 123 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 124 | % |
| 125 | % AcquireCacheViewPixels() gets pixels from the in-memory or disk pixel cache |
| 126 | % as defined by the geometry parameters. A pointer to the pixels is returned |
| 127 | % if the pixels are transferred, otherwise a NULL is returned. |
| 128 | % |
| 129 | % The format of the AcquireCacheViewPixels method is: |
| 130 | % |
| 131 | % const PixelPacket *AcquireCacheViewPixels(const ViewInfo *view_info, |
| 132 | % const long x,const long y,const unsigned long columns, |
| 133 | % const unsigned long rows,ExceptionInfo *exception) |
| 134 | % |
| 135 | % A description of each parameter follows: |
| 136 | % |
| 137 | % o view_info: The address of a structure of type ViewInfo. |
| 138 | % |
| 139 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 140 | % pixels. |
| 141 | % |
| 142 | % o exception: Return any errors or warnings in this structure. |
| 143 | % |
| 144 | */ |
| 145 | MagickExport const PixelPacket *AcquireCacheViewPixels( |
| 146 | const ViewInfo *view_info,const long x,const long y, |
| 147 | const unsigned long columns,const unsigned long rows,ExceptionInfo *exception) |
| 148 | { |
| 149 | const PixelPacket |
| 150 | *pixels; |
| 151 | |
| 152 | assert(view_info != (ViewInfo *) NULL); |
| 153 | assert(view_info->signature == MagickSignature); |
| 154 | assert(view_info->image != (Image *) NULL); |
| 155 | if (view_info->debug != MagickFalse) |
| 156 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 157 | view_info->image->filename); |
| 158 | pixels=AcquireCacheNexus(view_info->image,view_info->virtual_pixel_method,x,y, |
| 159 | columns,rows,view_info->id,exception); |
| 160 | return(pixels); |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 165 | % % |
| 166 | % % |
| 167 | % % |
| 168 | % A c q u i r e O n e C a c h e V i e w P i x e l % |
| 169 | % % |
| 170 | % % |
| 171 | % % |
| 172 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 173 | % |
| 174 | % AcquireCacheViewPixels() returns a single pixel at the specified (x,y) location. |
| 175 | % The image background color is returned if an error occurs. If you plan to |
| 176 | % modify the pixel, use GetOneCacheViewPixel() instead. |
| 177 | % |
| 178 | % The format of the AcquireOneCacheViewPixel method is: |
| 179 | % |
| 180 | % PixelPacket AcquireOneCacheViewPixel(const ViewInfo *view_info, |
| 181 | % const long x,const long y,ExceptionInfo *exception) |
| 182 | % |
| 183 | % A description of each parameter follows: |
| 184 | % |
| 185 | % o view_info: The address of a structure of type ViewInfo. |
| 186 | % |
| 187 | % o x,y: These values define the offset of the pixel. |
| 188 | % |
| 189 | % o exception: Return any errors or warnings in this structure. |
| 190 | % |
| 191 | */ |
| 192 | MagickExport PixelPacket AcquireOneCacheViewPixel(const ViewInfo *view_info, |
| 193 | const long x,const long y,ExceptionInfo *exception) |
| 194 | { |
| 195 | assert(view_info != (ViewInfo *) NULL); |
| 196 | assert(view_info->signature == MagickSignature); |
| 197 | assert(view_info->image != (Image *) NULL); |
| 198 | if (view_info->debug != MagickFalse) |
| 199 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 200 | view_info->image->filename); |
| 201 | return(AcquireOnePixel(view_info->image,x,y,exception)); |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 206 | % % |
| 207 | % % |
| 208 | % % |
| 209 | % C l o n e C a c h e V i e w % |
| 210 | % % |
| 211 | % % |
| 212 | % % |
| 213 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 214 | % |
| 215 | % CloneCacheView() makes an exact copy of the specified cache view. |
| 216 | % |
| 217 | % The format of the CloneCacheView method is: |
| 218 | % |
| 219 | % ViewInfo *CloneCacheView(const ViewInfo *view_info) |
| 220 | % |
| 221 | % A description of each parameter follows: |
| 222 | % |
| 223 | % o view_info: The cache view. |
| 224 | % |
| 225 | */ |
| 226 | MagickExport ViewInfo *CloneCacheView(const ViewInfo *view_info) |
| 227 | { |
| 228 | ViewInfo |
| 229 | *clone_view; |
| 230 | |
| 231 | assert(view_info != (ViewInfo *) NULL); |
| 232 | assert(view_info->signature == MagickSignature); |
| 233 | if (view_info->debug != MagickFalse) |
| 234 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 235 | view_info->image->filename); |
| 236 | clone_view=(ViewInfo *) AcquireMagickMemory(sizeof(*clone_view)); |
| 237 | if (clone_view == (ViewInfo *) NULL) |
| 238 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 239 | (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); |
| 240 | clone_view->image=ReferenceImage(view_info->image); |
| 241 | clone_view->id=GetNexus(clone_view->image->cache); |
| 242 | clone_view->virtual_pixel_method=view_info->virtual_pixel_method; |
| 243 | clone_view->debug=view_info->debug; |
| 244 | clone_view->signature=MagickSignature; |
| 245 | return(clone_view); |
| 246 | } |
| 247 | |
| 248 | /* |
| 249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 250 | % % |
| 251 | % % |
| 252 | % % |
| 253 | % C l o s e C a c h e V i e w % |
| 254 | % % |
| 255 | % % |
| 256 | % % |
| 257 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 258 | % |
| 259 | % CloseCacheView() closes the specified view returned by a previous call to |
| 260 | % OpenCacheView(). |
| 261 | % |
| 262 | % The format of the CloseCacheView method is: |
| 263 | % |
| 264 | % ViewInfo *CloseCacheView(ViewInfo *view_info) |
| 265 | % |
| 266 | % A description of each parameter follows: |
| 267 | % |
| 268 | % o view_info: The address of a structure of type ViewInfo. |
| 269 | % |
| 270 | */ |
| 271 | MagickExport ViewInfo *CloseCacheView(ViewInfo *view_info) |
| 272 | { |
| 273 | assert(view_info != (ViewInfo *) NULL); |
| 274 | assert(view_info->signature == MagickSignature); |
| 275 | assert(view_info->image != (Image *) NULL); |
| 276 | if (view_info->debug != MagickFalse) |
| 277 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 278 | view_info->image->filename); |
| 279 | if (view_info->id != 0) |
| 280 | DestroyCacheNexus(view_info->image->cache,view_info->id); |
| 281 | view_info->image=DestroyImage(view_info->image); |
| 282 | view_info->signature=(~MagickSignature); |
| 283 | view_info=(ViewInfo *) RelinquishMagickMemory(view_info); |
| 284 | return(view_info); |
| 285 | } |
| 286 | |
| 287 | /* |
| 288 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 289 | % % |
| 290 | % % |
| 291 | % % |
| 292 | % G e t C a c h e V i e w C o l o r s p a c e % |
| 293 | % % |
| 294 | % % |
| 295 | % % |
| 296 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 297 | % |
| 298 | % GetCacheViewColorspace() returns the image colorspace associated with the |
| 299 | % specified view. |
| 300 | % |
| 301 | % The format of the GetCacheViewColorspace method is: |
| 302 | % |
| 303 | % ColorspaceType GetCacheViewColorspace(const ViewInfo *view_info) |
| 304 | % |
| 305 | % A description of each parameter follows: |
| 306 | % |
| 307 | % o view_info: The address of a structure of type ViewInfo. |
| 308 | % |
| 309 | */ |
| 310 | MagickExport ColorspaceType GetCacheViewColorspace(const ViewInfo *view_info) |
| 311 | { |
| 312 | assert(view_info != (ViewInfo *) NULL); |
| 313 | assert(view_info->signature == MagickSignature); |
| 314 | assert(view_info->image != (Image *) NULL); |
| 315 | if (view_info->debug != MagickFalse) |
| 316 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 317 | view_info->image->filename); |
| 318 | return(view_info->image->colorspace); |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 323 | % % |
| 324 | % % |
| 325 | % % |
| 326 | % G e t C a c h e V i e w E x c e p t i o n % |
| 327 | % % |
| 328 | % % |
| 329 | % % |
| 330 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 331 | % |
| 332 | % GetCacheViewException() returns the image exception associated with the |
| 333 | % specified view. |
| 334 | % |
| 335 | % The format of the GetCacheViewException method is: |
| 336 | % |
| 337 | % ExceptionInfo GetCacheViewException(const ViewInfo *view_info) |
| 338 | % |
| 339 | % A description of each parameter follows: |
| 340 | % |
| 341 | % o view_info: The address of a structure of type ViewInfo. |
| 342 | % |
| 343 | */ |
| 344 | MagickExport ExceptionInfo *GetCacheViewException(const ViewInfo *view_info) |
| 345 | { |
| 346 | assert(view_info != (ViewInfo *) NULL); |
| 347 | assert(view_info->signature == MagickSignature); |
| 348 | assert(view_info->image != (Image *) NULL); |
| 349 | if (view_info->debug != MagickFalse) |
| 350 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 351 | view_info->image->filename); |
| 352 | return(&view_info->image->exception); |
| 353 | } |
| 354 | |
| 355 | /* |
| 356 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 357 | % % |
| 358 | % % |
| 359 | % % |
| 360 | % G e t C a c h e V i e w I n d e x e s % |
| 361 | % % |
| 362 | % % |
| 363 | % % |
| 364 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 365 | % |
| 366 | % GetCacheViewIndexes() returns the indexes associated with the specified |
| 367 | % view. |
| 368 | % |
| 369 | % The format of the GetCacheViewIndexes method is: |
| 370 | % |
| 371 | % IndexPacket *GetCacheViewIndexes(const ViewInfo *view_info) |
| 372 | % |
| 373 | % A description of each parameter follows: |
| 374 | % |
| 375 | % o view_info: The address of a structure of type ViewInfo. |
| 376 | % |
| 377 | */ |
| 378 | MagickExport IndexPacket *GetCacheViewIndexes(const ViewInfo *view_info) |
| 379 | { |
| 380 | assert(view_info != (ViewInfo *) NULL); |
| 381 | assert(view_info->signature == MagickSignature); |
| 382 | assert(view_info->image != (Image *) NULL); |
| 383 | if (view_info->debug != MagickFalse) |
| 384 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 385 | view_info->image->filename); |
| 386 | return(GetNexusIndexes(view_info->image->cache,view_info->id)); |
| 387 | } |
| 388 | |
| 389 | /* |
| 390 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 391 | % % |
| 392 | % % |
| 393 | % % |
| 394 | % G e t C a c h e V i e w P i x e l s % |
| 395 | % % |
| 396 | % % |
| 397 | % % |
| 398 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 399 | % |
| 400 | % GetCacheViewPixels() gets pixels from the in-memory or disk pixel cache as |
| 401 | % defined by the geometry parameters. A pointer to the pixels is returned if |
| 402 | % the pixels are transferred, otherwise a NULL is returned. |
| 403 | % |
| 404 | % The format of the GetCacheViewPixels method is: |
| 405 | % |
| 406 | % PixelPacket *GetCacheViewPixels(ViewInfo *view_info,const long x, |
| 407 | % const long y,const unsigned long columns,const unsigned long rows) |
| 408 | % |
| 409 | % A description of each parameter follows: |
| 410 | % |
| 411 | % o view_info: The address of a structure of type ViewInfo. |
| 412 | % |
| 413 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 414 | % pixels. |
| 415 | % |
| 416 | */ |
| 417 | MagickExport PixelPacket *GetCacheViewPixels(ViewInfo *view_info,const long x, |
| 418 | const long y,const unsigned long columns,const unsigned long rows) |
| 419 | { |
| 420 | assert(view_info != (ViewInfo *) NULL); |
| 421 | assert(view_info->signature == MagickSignature); |
| 422 | assert(view_info->image != (Image *) NULL); |
| 423 | if (view_info->debug != MagickFalse) |
| 424 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 425 | view_info->image->filename); |
| 426 | return(GetCacheNexus(view_info->image,x,y,columns,rows,view_info->id)); |
| 427 | } |
| 428 | |
| 429 | /* |
| 430 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 431 | % % |
| 432 | % % |
| 433 | % % |
| 434 | % G e t C a c h e V i e w S t o r a g e C l a s s % |
| 435 | % % |
| 436 | % % |
| 437 | % % |
| 438 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 439 | % |
| 440 | % GetCacheViewStorageClass() returns the image storage class associated with |
| 441 | % the specified view. |
| 442 | % |
| 443 | % The format of the GetCacheViewStorageClass method is: |
| 444 | % |
| 445 | % ClassType GetCacheViewStorageClass(const ViewInfo *view_info) |
| 446 | % |
| 447 | % A description of each parameter follows: |
| 448 | % |
| 449 | % o view_info: The address of a structure of type ViewInfo. |
| 450 | % |
| 451 | */ |
| 452 | MagickExport ClassType GetCacheViewStorageClass(const ViewInfo *view_info) |
| 453 | { |
| 454 | assert(view_info != (ViewInfo *) NULL); |
| 455 | assert(view_info->signature == MagickSignature); |
| 456 | assert(view_info->image != (Image *) NULL); |
| 457 | if (view_info->debug != MagickFalse) |
| 458 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 459 | view_info->image->filename); |
| 460 | return(view_info->image->storage_class); |
| 461 | } |
| 462 | |
| 463 | /* |
| 464 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 465 | % % |
| 466 | % % |
| 467 | % % |
| 468 | % G e t O n e C a c h e V i e w P i x e l % |
| 469 | % % |
| 470 | % % |
| 471 | % % |
| 472 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 473 | % |
| 474 | % GetOneCacheViewPixel() returns a single pixel at the specified (x,y) |
| 475 | % location. The image background color is returned if an error occurs. |
| 476 | % |
| 477 | % The format of the GetOneCacheViewPixel method is: |
| 478 | % |
| 479 | % PixelPacket GetOneCacheViewPixel(const ViewInfo *view_info, |
| 480 | % const long x,const long y) |
| 481 | % |
| 482 | % A description of each parameter follows: |
| 483 | % |
| 484 | % o view_info: The address of a structure of type ViewInfo. |
| 485 | % |
| 486 | % o x,y: These values define the offset of the pixel. |
| 487 | % |
| 488 | */ |
| 489 | MagickExport PixelPacket GetOneCacheViewPixel(const ViewInfo *view_info, |
| 490 | const long x,const long y) |
| 491 | { |
| 492 | assert(view_info != (ViewInfo *) NULL); |
| 493 | assert(view_info->signature == MagickSignature); |
| 494 | assert(view_info->image != (Image *) NULL); |
| 495 | if (view_info->debug != MagickFalse) |
| 496 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 497 | view_info->image->filename); |
| 498 | return(GetOnePixel(view_info->image,x,y)); |
| 499 | } |
| 500 | |
| 501 | /* |
| 502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 503 | % % |
| 504 | % % |
| 505 | % % |
| 506 | % O p e n C a c h e V i e w % |
| 507 | % % |
| 508 | % % |
| 509 | % % |
| 510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 511 | % |
| 512 | % OpenCacheView() opens a view into the pixel cache, using the |
| 513 | % VirtualPixelMethod that is defined within the given image itself. |
| 514 | % |
| 515 | % The format of the OpenCacheView method is: |
| 516 | % |
| 517 | % ViewInfo *OpenCacheView(const Image *image) |
| 518 | % |
| 519 | % A description of each parameter follows: |
| 520 | % |
| 521 | % o image: The image. |
| 522 | % |
| 523 | */ |
| 524 | MagickExport ViewInfo *OpenCacheView(const Image *image) |
| 525 | { |
| 526 | ViewInfo |
| 527 | *view_info; |
| 528 | |
| 529 | assert(image != (Image *) NULL); |
| 530 | assert(image->signature == MagickSignature); |
| 531 | if (image->debug != MagickFalse) |
| 532 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 533 | view_info=(ViewInfo *) AcquireMagickMemory(sizeof(*view_info)); |
| 534 | if (view_info == (ViewInfo *) NULL) |
| 535 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 536 | (void) ResetMagickMemory(view_info,0,sizeof(*view_info)); |
| 537 | view_info->image=ReferenceImage((Image *) image); |
| 538 | view_info->id=GetNexus(view_info->image->cache); |
| 539 | view_info->virtual_pixel_method=GetImageVirtualPixelMethod(image); |
| 540 | view_info->debug=IsEventLogging(); |
| 541 | view_info->signature=MagickSignature; |
| 542 | return(view_info); |
| 543 | } |
| 544 | |
| 545 | /* |
| 546 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 547 | % % |
| 548 | % % |
| 549 | % % |
| 550 | % S e t C a c h e V i e w % |
| 551 | % % |
| 552 | % % |
| 553 | % % |
| 554 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 555 | % |
| 556 | % SetCacheView() gets pixels from the in-memory or disk pixel cache as |
| 557 | % defined by the geometry parameters. A pointer to the pixels is returned |
| 558 | % if the pixels are transferred, otherwise a NULL is returned. |
| 559 | % |
| 560 | % The format of the SetCacheView method is: |
| 561 | % |
| 562 | % PixelPacket *SetCacheView(ViewInfo *view_info,const long x,const long y, |
| 563 | % const unsigned long columns,const unsigned long rows) |
| 564 | % |
| 565 | % A description of each parameter follows: |
| 566 | % |
| 567 | % o view_info: The address of a structure of type ViewInfo. |
| 568 | % |
| 569 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 570 | % pixels. |
| 571 | % |
| 572 | */ |
| 573 | MagickExport PixelPacket *SetCacheView(ViewInfo *view_info,const long x, |
| 574 | const long y,const unsigned long columns,const unsigned long rows) |
| 575 | { |
| 576 | assert(view_info != (ViewInfo *) NULL); |
| 577 | assert(view_info->signature == MagickSignature); |
| 578 | assert(view_info->image != (Image *) NULL); |
| 579 | if (view_info->debug != MagickFalse) |
| 580 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 581 | view_info->image->filename); |
| 582 | return(SetCacheNexus(view_info->image,x,y,columns,rows,view_info->id)); |
| 583 | } |
| 584 | |
| 585 | /* |
| 586 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 587 | % % |
| 588 | % % |
| 589 | % % |
| 590 | % S e t C a c h e V i e w S t o r a g e C l a s s % |
| 591 | % % |
| 592 | % % |
| 593 | % % |
| 594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 595 | % |
| 596 | % SetCacheViewStorageClass() sets the image storage class associated with |
| 597 | % the specified view. |
| 598 | % |
| 599 | % The format of the SetCacheViewStorageClass method is: |
| 600 | % |
| 601 | % MagickBooleanType SetCacheViewStorageClass(ViewInfo *view_info, |
| 602 | % const ClassType storage_class) |
| 603 | % |
| 604 | % A description of each parameter follows: |
| 605 | % |
| 606 | % o view_info: The address of a structure of type ViewInfo. |
| 607 | % |
| 608 | % o storage_class: The image storage class: PseudoClass or DirectClass. |
| 609 | % |
| 610 | */ |
| 611 | MagickExport MagickBooleanType SetCacheViewStorageClass(ViewInfo *view_info, |
| 612 | const ClassType storage_class) |
| 613 | { |
| 614 | assert(view_info != (ViewInfo *) NULL); |
| 615 | assert(view_info->signature == MagickSignature); |
| 616 | assert(view_info->image != (Image *) NULL); |
| 617 | if (view_info->debug != MagickFalse) |
| 618 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 619 | view_info->image->filename); |
| 620 | return(SetImageStorageClass(view_info->image,storage_class)); |
| 621 | } |
| 622 | |
| 623 | /* |
| 624 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 625 | % % |
| 626 | % % |
| 627 | % % |
| 628 | % 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 % |
| 629 | % % |
| 630 | % % |
| 631 | % % |
| 632 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 633 | % |
| 634 | % SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated |
| 635 | % with the specified cache view. |
| 636 | % |
| 637 | % The format of the SetCacheViewVirtualPixelMethod method is: |
| 638 | % |
| 639 | % MagickBooleanType SetCacheViewVirtualPixelMethod(ViewInfo *view_info, |
| 640 | % const VirtualPixelMethod virtual_pixel_method) |
| 641 | % |
| 642 | % A description of each parameter follows: |
| 643 | % |
| 644 | % o view_info: The address of a structure of type ViewInfo. |
| 645 | % |
| 646 | % o virtual_pixel_method: The virtual pixel method. |
| 647 | % |
| 648 | */ |
| 649 | MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod( |
| 650 | ViewInfo *view_info,const VirtualPixelMethod virtual_pixel_method) |
| 651 | { |
| 652 | assert(view_info != (ViewInfo *) NULL); |
| 653 | assert(view_info->signature == MagickSignature); |
| 654 | assert(view_info->image != (Image *) NULL); |
| 655 | if (view_info->debug != MagickFalse) |
| 656 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 657 | view_info->image->filename); |
| 658 | view_info->virtual_pixel_method=virtual_pixel_method; |
| 659 | return(MagickTrue); |
| 660 | } |
| 661 | |
| 662 | /* |
| 663 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 664 | % % |
| 665 | % % |
| 666 | % % |
| 667 | % S y n c C a c h e V i e w % |
| 668 | % % |
| 669 | % % |
| 670 | % % |
| 671 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 672 | % |
| 673 | % SyncCacheView() saves the view_info pixels to the in-memory or disk cache. |
| 674 | % The method returns MagickTrue if the pixel region is synced, otherwise |
| 675 | % MagickFalse. |
| 676 | % |
| 677 | % The format of the SyncCacheView method is: |
| 678 | % |
| 679 | % MagickBooleanType SyncCacheView(ViewInfo *view_info) |
| 680 | % |
| 681 | % A description of each parameter follows: |
| 682 | % |
| 683 | % o view_info: The address of a structure of type ViewInfo. |
| 684 | % |
| 685 | */ |
| 686 | MagickExport MagickBooleanType SyncCacheView(ViewInfo *view_info) |
| 687 | { |
| 688 | assert(view_info != (ViewInfo *) NULL); |
| 689 | assert(view_info->signature == MagickSignature); |
| 690 | assert(view_info->image != (Image *) NULL); |
| 691 | if (view_info->debug != MagickFalse) |
| 692 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 693 | view_info->image->filename); |
| 694 | return(SyncCacheNexus(view_info->image,view_info->id)); |
| 695 | } |
Note: See TracBrowser
for help on using the browser.
