MagickCore  6.7.5
cache-view.c
Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %                      CCCC   AAA    CCCC  H   H  EEEEE                       %
00007 %                     C      A   A  C      H   H  E                           %
00008 %                     C      AAAAA  C      HHHHH  EEE                         %
00009 %                     C      A   A  C      H   H  E                           %
00010 %                      CCCC  A   A   CCCC  H   H  EEEEE                       %
00011 %                                                                             %
00012 %                        V   V  IIIII  EEEEE  W   W                           %
00013 %                        V   V    I    E      W   W                           %
00014 %                        V   V    I    EEE    W W W                           %
00015 %                         V V     I    E      WW WW                           %
00016 %                          V    IIIII  EEEEE  W   W                           %
00017 %                                                                             %
00018 %                                                                             %
00019 %                        MagickCore Cache View Methods                        %
00020 %                                                                             %
00021 %                              Software Design                                %
00022 %                                John Cristy                                  %
00023 %                               February 2000                                 %
00024 %                                                                             %
00025 %                                                                             %
00026 %  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
00027 %  dedicated to making software imaging solutions freely available.           %
00028 %                                                                             %
00029 %  You may not use this file except in compliance with the License.  You may  %
00030 %  obtain a copy of the License at                                            %
00031 %                                                                             %
00032 %    http://www.imagemagick.org/script/license.php                            %
00033 %                                                                             %
00034 %  Unless required by applicable law or agreed to in writing, software        %
00035 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00036 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00037 %  See the License for the specific language governing permissions and        %
00038 %  limitations under the License.                                             %
00039 %                                                                             %
00040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00041 %
00042 %
00043 %
00044 */
00045 
00046 /*
00047   Include declarations.
00048 */
00049 #include "MagickCore/studio.h"
00050 #include "MagickCore/cache.h"
00051 #include "MagickCore/cache-private.h"
00052 #include "MagickCore/cache-view.h"
00053 #include "MagickCore/memory_.h"
00054 #include "MagickCore/exception.h"
00055 #include "MagickCore/exception-private.h"
00056 #include "MagickCore/pixel-accessor.h"
00057 #include "MagickCore/string_.h"
00058 #include "MagickCore/thread-private.h"
00059 
00060 /*
00061   Typedef declarations.
00062 */
00063 struct _CacheView
00064 {
00065   Image
00066     *image;
00067 
00068   VirtualPixelMethod
00069     virtual_pixel_method;
00070 
00071   size_t
00072     number_threads;
00073 
00074   NexusInfo
00075     **nexus_info;
00076 
00077   MagickBooleanType
00078     debug;
00079 
00080   size_t
00081     signature;
00082 };
00083 
00084 /*
00085 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00086 %                                                                             %
00087 %                                                                             %
00088 %                                                                             %
00089 %   A c q u i r e C a c h e V i e w                                           %
00090 %                                                                             %
00091 %                                                                             %
00092 %                                                                             %
00093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00094 %
00095 %  AcquireCacheView() acquires a view into the pixel cache, using the
00096 %  VirtualPixelMethod that is defined within the given image itself.
00097 %
00098 %  The format of the AcquireCacheView method is:
00099 %
00100 %      CacheView *AcquireCacheView(const Image *image)
00101 %
00102 %  A description of each parameter follows:
00103 %
00104 %    o image: the image.
00105 %
00106 */
00107 MagickExport CacheView *AcquireCacheView(const Image *image)
00108 {
00109   CacheView
00110     *cache_view;
00111 
00112   assert(image != (Image *) NULL);
00113   assert(image->signature == MagickSignature);
00114   if (image->debug != MagickFalse)
00115     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00116   cache_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*cache_view));
00117   if (cache_view == (CacheView *) NULL)
00118     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00119   (void) ResetMagickMemory(cache_view,0,sizeof(*cache_view));
00120   cache_view->image=ReferenceImage((Image *) image);
00121   cache_view->number_threads=GetOpenMPMaximumThreads();
00122   cache_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
00123   cache_view->virtual_pixel_method=GetImageVirtualPixelMethod(image);
00124   cache_view->debug=IsEventLogging();
00125   cache_view->signature=MagickSignature;
00126   if (cache_view->nexus_info == (NexusInfo **) NULL)
00127     ThrowFatalException(CacheFatalError,"UnableToAcquireCacheView");
00128   return(cache_view);
00129 }
00130 
00131 /*
00132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00133 %                                                                             %
00134 %                                                                             %
00135 %                                                                             %
00136 %   C l o n e C a c h e V i e w                                               %
00137 %                                                                             %
00138 %                                                                             %
00139 %                                                                             %
00140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00141 %
00142 %  CloneCacheView()  makes an exact copy of the specified cache view.
00143 %
00144 %  The format of the CloneCacheView method is:
00145 %
00146 %      CacheView *CloneCacheView(const CacheView *cache_view)
00147 %
00148 %  A description of each parameter follows:
00149 %
00150 %    o cache_view: the cache view.
00151 %
00152 */
00153 MagickExport CacheView *CloneCacheView(const CacheView *cache_view)
00154 {
00155   CacheView
00156     *clone_view;
00157 
00158   assert(cache_view != (CacheView *) NULL);
00159   assert(cache_view->signature == MagickSignature);
00160   if (cache_view->debug != MagickFalse)
00161     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00162       cache_view->image->filename);
00163   clone_view=(CacheView *) AcquireQuantumMemory(1,sizeof(*clone_view));
00164   if (clone_view == (CacheView *) NULL)
00165     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00166   (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view));
00167   clone_view->image=ReferenceImage(cache_view->image);
00168   clone_view->number_threads=cache_view->number_threads;
00169   clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads);
00170   clone_view->virtual_pixel_method=cache_view->virtual_pixel_method;
00171   clone_view->debug=cache_view->debug;
00172   clone_view->signature=MagickSignature;
00173   return(clone_view);
00174 }
00175 
00176 /*
00177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00178 %                                                                             %
00179 %                                                                             %
00180 %                                                                             %
00181 %   D e s t r o y C a c h e V i e w                                           %
00182 %                                                                             %
00183 %                                                                             %
00184 %                                                                             %
00185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00186 %
00187 %  DestroyCacheView() destroys the specified view returned by a previous call
00188 %  to AcquireCacheView().
00189 %
00190 %  The format of the DestroyCacheView method is:
00191 %
00192 %      CacheView *DestroyCacheView(CacheView *cache_view)
00193 %
00194 %  A description of each parameter follows:
00195 %
00196 %    o cache_view: the cache view.
00197 %
00198 */
00199 MagickExport CacheView *DestroyCacheView(CacheView *cache_view)
00200 {
00201   assert(cache_view != (CacheView *) NULL);
00202   assert(cache_view->signature == MagickSignature);
00203   if (cache_view->debug != MagickFalse)
00204     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00205       cache_view->image->filename);
00206   if (cache_view->nexus_info != (NexusInfo **) NULL)
00207     cache_view->nexus_info=DestroyPixelCacheNexus(cache_view->nexus_info,
00208       cache_view->number_threads);
00209   cache_view->image=DestroyImage(cache_view->image);
00210   cache_view->signature=(~MagickSignature);
00211   cache_view=(CacheView *) RelinquishMagickMemory(cache_view);
00212   return(cache_view);
00213 }
00214 
00215 /*
00216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00217 %                                                                             %
00218 %                                                                             %
00219 %                                                                             %
00220 %   G e t C a c h e V i e w C o l o r s p a c e                               %
00221 %                                                                             %
00222 %                                                                             %
00223 %                                                                             %
00224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00225 %
00226 %  GetCacheViewColorspace() returns the image colorspace associated with the
00227 %  specified view.
00228 %
00229 %  The format of the GetCacheViewColorspace method is:
00230 %
00231 %      ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
00232 %
00233 %  A description of each parameter follows:
00234 %
00235 %    o cache_view: the cache view.
00236 %
00237 */
00238 MagickExport ColorspaceType GetCacheViewColorspace(const CacheView *cache_view)
00239 {
00240   assert(cache_view != (CacheView *) NULL);
00241   assert(cache_view->signature == MagickSignature);
00242   if (cache_view->debug != MagickFalse)
00243     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00244       cache_view->image->filename);
00245   return(GetPixelCacheColorspace(cache_view->image->cache));
00246 }
00247 
00248 /*
00249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00250 %                                                                             %
00251 %                                                                             %
00252 %                                                                             %
00253 +   G e t C a c h e V i e w E x t e n t                                       %
00254 %                                                                             %
00255 %                                                                             %
00256 %                                                                             %
00257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00258 %
00259 %  GetCacheViewExtent() returns the extent of the pixels associated with the
00260 %  last call to QueueCacheViewAuthenticPixels() or
00261 %  GetCacheViewAuthenticPixels().
00262 %
00263 %  The format of the GetCacheViewExtent() method is:
00264 %
00265 %      MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
00266 %
00267 %  A description of each parameter follows:
00268 %
00269 %    o cache_view: the cache view.
00270 %
00271 */
00272 MagickExport MagickSizeType GetCacheViewExtent(const CacheView *cache_view)
00273 {
00274   const int
00275     id = GetOpenMPThreadId();
00276 
00277   MagickSizeType
00278     extent;
00279 
00280   assert(cache_view != (CacheView *) NULL);
00281   assert(cache_view->signature == MagickSignature);
00282   if (cache_view->debug != MagickFalse)
00283     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00284       cache_view->image->filename);
00285   assert(cache_view->image->cache != (Cache) NULL);
00286   assert(id < (int) cache_view->number_threads);
00287   extent=GetPixelCacheNexusExtent(cache_view->image->cache,
00288     cache_view->nexus_info[id]);
00289   return(extent);
00290 }
00291 
00292 /*
00293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00294 %                                                                             %
00295 %                                                                             %
00296 %                                                                             %
00297 %   G e t C a c h e V i e w S t o r a g e C l a s s                           %
00298 %                                                                             %
00299 %                                                                             %
00300 %                                                                             %
00301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00302 %
00303 %  GetCacheViewStorageClass() returns the image storage class  associated with
00304 %  the specified view.
00305 %
00306 %  The format of the GetCacheViewStorageClass method is:
00307 %
00308 %      ClassType GetCacheViewStorageClass(const CacheView *cache_view)
00309 %
00310 %  A description of each parameter follows:
00311 %
00312 %    o cache_view: the cache view.
00313 %
00314 */
00315 MagickExport ClassType GetCacheViewStorageClass(const CacheView *cache_view)
00316 {
00317   assert(cache_view != (CacheView *) NULL);
00318   assert(cache_view->signature == MagickSignature);
00319   if (cache_view->debug != MagickFalse)
00320     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00321       cache_view->image->filename);
00322   return(GetPixelCacheStorageClass(cache_view->image->cache));
00323 }
00324 
00325 /*
00326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00327 %                                                                             %
00328 %                                                                             %
00329 %                                                                             %
00330 %   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                     %
00331 %                                                                             %
00332 %                                                                             %
00333 %                                                                             %
00334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00335 %
00336 %  GetCacheViewAuthenticPixels() gets pixels from the in-memory or disk pixel
00337 %  cache as defined by the geometry parameters.   A pointer to the pixels is
00338 %  returned if the pixels are transferred, otherwise a NULL is returned.
00339 %
00340 %  The format of the GetCacheViewAuthenticPixels method is:
00341 %
00342 %      Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
00343 %        const ssize_t x,const ssize_t y,const size_t columns,
00344 %        const size_t rows,ExceptionInfo *exception)
00345 %
00346 %  A description of each parameter follows:
00347 %
00348 %    o cache_view: the cache view.
00349 %
00350 %    o x,y,columns,rows:  These values define the perimeter of a region of
00351 %      pixels.
00352 %
00353 */
00354 MagickExport Quantum *GetCacheViewAuthenticPixels(CacheView *cache_view,
00355   const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
00356   ExceptionInfo *exception)
00357 {
00358   const int
00359     id = GetOpenMPThreadId();
00360 
00361   Quantum
00362     *pixels;
00363 
00364   assert(cache_view != (CacheView *) NULL);
00365   assert(cache_view->signature == MagickSignature);
00366   assert(id < (int) cache_view->number_threads);
00367   pixels=GetAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
00368     cache_view->nexus_info[id],exception);
00369   return(pixels);
00370 }
00371 
00372 /*
00373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00374 %                                                                             %
00375 %                                                                             %
00376 %                                                                             %
00377 %   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           %
00378 %                                                                             %
00379 %                                                                             %
00380 %                                                                             %
00381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00382 %
00383 %  GetCacheViewAuthenticMetacontent() returns the meta-content corresponding
00384 %  with the last call to SetCacheViewIndexes() or
00385 %  GetCacheViewAuthenticMetacontent().  The meta-content are authentic and can
00386 %  be updated.
00387 %
00388 %  The format of the GetCacheViewAuthenticMetacontent() method is:
00389 %
00390 %      void *GetCacheViewAuthenticMetacontent(CacheView *cache_view)
00391 %
00392 %  A description of each parameter follows:
00393 %
00394 %    o cache_view: the cache view.
00395 %
00396 */
00397 MagickExport void *GetCacheViewAuthenticMetacontent(
00398   CacheView *cache_view)
00399 {
00400   const int
00401     id = GetOpenMPThreadId();
00402 
00403   void
00404     *metacontent;
00405 
00406   assert(cache_view != (CacheView *) NULL);
00407   assert(cache_view->signature == MagickSignature);
00408   assert(cache_view->image->cache != (Cache) NULL);
00409   assert(id < (int) cache_view->number_threads);
00410   metacontent=GetPixelCacheNexusMetacontent(cache_view->image->cache,
00411     cache_view->nexus_info[id]);
00412   return(metacontent);
00413 }
00414 
00415 /*
00416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00417 %                                                                             %
00418 %                                                                             %
00419 %                                                                             %
00420 %   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             %
00421 %                                                                             %
00422 %                                                                             %
00423 %                                                                             %
00424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00425 %
00426 %  GetCacheViewAuthenticPixelQueue() returns the pixels associated with the
00427 %  last call to QueueCacheViewAuthenticPixels() or
00428 %  GetCacheViewAuthenticPixels().  The pixels are authentic and therefore can be
00429 %  updated.
00430 %
00431 %  The format of the GetCacheViewAuthenticPixelQueue() method is:
00432 %
00433 %      Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
00434 %
00435 %  A description of each parameter follows:
00436 %
00437 %    o cache_view: the cache view.
00438 %
00439 */
00440 MagickExport Quantum *GetCacheViewAuthenticPixelQueue(CacheView *cache_view)
00441 {
00442   const int
00443     id = GetOpenMPThreadId();
00444 
00445   Quantum
00446     *pixels;
00447 
00448   assert(cache_view != (CacheView *) NULL);
00449   assert(cache_view->signature == MagickSignature);
00450   assert(cache_view->image->cache != (Cache) NULL);
00451   assert(id < (int) cache_view->number_threads);
00452   pixels=GetPixelCacheNexusPixels(cache_view->image->cache,
00453     cache_view->nexus_info[id]);
00454   return(pixels);
00455 }
00456 
00457 /*
00458 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00459 %                                                                             %
00460 %                                                                             %
00461 %                                                                             %
00462 %   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               %
00463 %                                                                             %
00464 %                                                                             %
00465 %                                                                             %
00466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00467 %
00468 %  GetCacheViewVirtualMetacontent() returns the meta-content corresponding
00469 %  with the last call to GetCacheViewVirtualMetacontent().  The meta-content
00470 %  is virtual and therefore cannot be updated.
00471 %
00472 %  The format of the GetCacheViewVirtualMetacontent() method is:
00473 %
00474 %      const void *GetCacheViewVirtualMetacontent(
00475 %        const CacheView *cache_view)
00476 %
00477 %  A description of each parameter follows:
00478 %
00479 %    o cache_view: the cache view.
00480 %
00481 */
00482 MagickExport const void *GetCacheViewVirtualMetacontent(
00483   const CacheView *cache_view)
00484 {
00485   const int
00486     id = GetOpenMPThreadId();
00487 
00488   const void
00489     *metacontent;
00490 
00491   assert(cache_view != (const CacheView *) NULL);
00492   assert(cache_view->signature == MagickSignature);
00493   assert(cache_view->image->cache != (Cache) NULL);
00494   assert(id < (int) cache_view->number_threads);
00495   metacontent=GetVirtualMetacontentFromNexus(cache_view->image->cache,
00496     cache_view->nexus_info[id]);
00497   return(metacontent);
00498 }
00499 
00500 /*
00501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00502 %                                                                             %
00503 %                                                                             %
00504 %                                                                             %
00505 %   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                 %
00506 %                                                                             %
00507 %                                                                             %
00508 %                                                                             %
00509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00510 %
00511 %  GetCacheViewVirtualPixelQueue() returns the the pixels associated with
00512 %  the last call to GetCacheViewVirtualPixels().  The pixels are virtual
00513 %  and therefore cannot be updated.
00514 %
00515 %  The format of the GetCacheViewVirtualPixelQueue() method is:
00516 %
00517 %      const Quantum *GetCacheViewVirtualPixelQueue(
00518 %        const CacheView *cache_view)
00519 %
00520 %  A description of each parameter follows:
00521 %
00522 %    o cache_view: the cache view.
00523 %
00524 */
00525 MagickExport const Quantum *GetCacheViewVirtualPixelQueue(
00526   const CacheView *cache_view)
00527 {
00528   const int
00529     id = GetOpenMPThreadId();
00530 
00531   const Quantum
00532     *pixels;
00533 
00534   assert(cache_view != (const CacheView *) NULL);
00535   assert(cache_view->signature == MagickSignature);
00536   assert(cache_view->image->cache != (Cache) NULL);
00537   assert(id < (int) cache_view->number_threads);
00538   pixels=GetVirtualPixelsNexus(cache_view->image->cache,
00539     cache_view->nexus_info[id]);
00540   return(pixels);
00541 }
00542 
00543 /*
00544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00545 %                                                                             %
00546 %                                                                             %
00547 %                                                                             %
00548 %   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                         %
00549 %                                                                             %
00550 %                                                                             %
00551 %                                                                             %
00552 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00553 %
00554 %  GetCacheViewVirtualPixels() gets virtual pixels from the in-memory or
00555 %  disk pixel cache as defined by the geometry parameters.   A pointer to the
00556 %  pixels is returned if the pixels are transferred, otherwise a NULL is
00557 %  returned.
00558 %
00559 %  The format of the GetCacheViewVirtualPixels method is:
00560 %
00561 %      const Quantum *GetCacheViewVirtualPixels(
00562 %        const CacheView *cache_view,const ssize_t x,const ssize_t y,
00563 %        const size_t columns,const size_t rows,ExceptionInfo *exception)
00564 %
00565 %  A description of each parameter follows:
00566 %
00567 %    o cache_view: the cache view.
00568 %
00569 %    o x,y,columns,rows:  These values define the perimeter of a region of
00570 %      pixels.
00571 %
00572 %    o exception: return any errors or warnings in this structure.
00573 %
00574 */
00575 MagickExport const Quantum *GetCacheViewVirtualPixels(
00576   const CacheView *cache_view,const ssize_t x,const ssize_t y,
00577   const size_t columns,const size_t rows,ExceptionInfo *exception)
00578 {
00579   const int
00580     id = GetOpenMPThreadId();
00581 
00582   const Quantum
00583     *pixels;
00584 
00585   assert(cache_view != (CacheView *) NULL);
00586   assert(cache_view->signature == MagickSignature);
00587   assert(id < (int) cache_view->number_threads);
00588   pixels=GetVirtualPixelsFromNexus(cache_view->image,
00589     cache_view->virtual_pixel_method,x,y,columns,rows,
00590     cache_view->nexus_info[id],exception);
00591   return(pixels);
00592 }
00593 
00594 /*
00595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00596 %                                                                             %
00597 %                                                                             %
00598 %                                                                             %
00599 %   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                 %
00600 %                                                                             %
00601 %                                                                             %
00602 %                                                                             %
00603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00604 %
00605 %  GetOneCacheViewAuthenticPixel() returns a single pixel at the specified (x,y)
00606 %  location.  The image background color is returned if an error occurs.
00607 %
00608 %  The format of the GetOneCacheViewAuthenticPixel method is:
00609 %
00610 %      MagickBooleaNType GetOneCacheViewAuthenticPixel(
00611 %        const CacheView *cache_view,const ssize_t x,const ssize_t y,
00612 %        Quantum *pixel,ExceptionInfo *exception)
00613 %
00614 %  A description of each parameter follows:
00615 %
00616 %    o cache_view: the cache view.
00617 %
00618 %    o x,y:  These values define the offset of the pixel.
00619 %
00620 %    o pixel: return a pixel at the specified (x,y) location.
00621 %
00622 %    o exception: return any errors or warnings in this structure.
00623 %
00624 */
00625 MagickExport MagickBooleanType GetOneCacheViewAuthenticPixel(
00626   const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
00627   ExceptionInfo *exception)
00628 {
00629   const int
00630     id = GetOpenMPThreadId();
00631 
00632   Quantum
00633     *p;
00634 
00635   register ssize_t
00636     i;
00637 
00638   assert(cache_view != (CacheView *) NULL);
00639   assert(cache_view->signature == MagickSignature);
00640   assert(id < (int) cache_view->number_threads);
00641   (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
00642   p=GetAuthenticPixelCacheNexus(cache_view->image,x,y,1,1,
00643     cache_view->nexus_info[id],exception);
00644   if (p == (const Quantum *) NULL)
00645     {
00646       PixelInfo
00647         background_color;
00648 
00649       background_color=cache_view->image->background_color;
00650       pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
00651       pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
00652       pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
00653       pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
00654       pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
00655       return(MagickFalse);
00656     }
00657   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
00658   {
00659     PixelChannel
00660       channel;
00661 
00662     channel=GetPixelChannelMapChannel(cache_view->image,i);
00663     pixel[channel]=p[i];
00664   }
00665   return(MagickTrue);
00666 }
00667 
00668 /*
00669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00670 %                                                                             %
00671 %                                                                             %
00672 %                                                                             %
00673 %   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                     %
00674 %                                                                             %
00675 %                                                                             %
00676 %                                                                             %
00677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00678 %
00679 %  GetOneCacheViewVirtualPixel() returns a single pixel at the specified (x,y)
00680 %  location.  The image background color is returned if an error occurs.  If
00681 %  you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
00682 %
00683 %  The format of the GetOneCacheViewVirtualPixel method is:
00684 %
00685 %      MagickBooleanType GetOneCacheViewVirtualPixel(
00686 %        const CacheView *cache_view,const ssize_t x,const ssize_t y,
00687 %        Quantum *pixel,ExceptionInfo *exception)
00688 %
00689 %  A description of each parameter follows:
00690 %
00691 %    o cache_view: the cache view.
00692 %
00693 %    o x,y:  These values define the offset of the pixel.
00694 %
00695 %    o pixel: return a pixel at the specified (x,y) location.
00696 %
00697 %    o exception: return any errors or warnings in this structure.
00698 %
00699 */
00700 MagickExport MagickBooleanType GetOneCacheViewVirtualPixel(
00701   const CacheView *cache_view,const ssize_t x,const ssize_t y,Quantum *pixel,
00702   ExceptionInfo *exception)
00703 {
00704   const int
00705     id = GetOpenMPThreadId();
00706 
00707   const Quantum
00708     *p;
00709 
00710   register ssize_t
00711     i;
00712 
00713   assert(cache_view != (CacheView *) NULL);
00714   assert(cache_view->signature == MagickSignature);
00715   assert(id < (int) cache_view->number_threads);
00716   (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
00717   p=GetVirtualPixelsFromNexus(cache_view->image,
00718     cache_view->virtual_pixel_method,x,y,1,1,cache_view->nexus_info[id],
00719     exception);
00720   if (p == (const Quantum *) NULL)
00721     {
00722       PixelInfo
00723         background_color;
00724 
00725       background_color=cache_view->image->background_color;
00726       pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
00727       pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
00728       pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
00729       pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
00730       pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
00731       return(MagickFalse);
00732     }
00733   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
00734   {
00735     PixelChannel
00736       channel;
00737 
00738     channel=GetPixelChannelMapChannel(cache_view->image,i);
00739     pixel[channel]=p[i];
00740   }
00741   return(MagickTrue);
00742 }
00743 
00744 /*
00745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00746 %                                                                             %
00747 %                                                                             %
00748 %                                                                             %
00749 %   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                     %
00750 %                                                                             %
00751 %                                                                             %
00752 %                                                                             %
00753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00754 %
00755 %  GetOneCacheViewVirtualMethodPixel() returns a single virtual pixel at
00756 %  the specified (x,y) location.  The image background color is returned if an
00757 %  error occurs.  If you plan to modify the pixel, use
00758 %  GetOneCacheViewAuthenticPixel() instead.
00759 %
00760 %  The format of the GetOneCacheViewVirtualPixel method is:
00761 %
00762 %      MagickBooleanType GetOneCacheViewVirtualMethodPixel(
00763 %        const CacheView *cache_view,
00764 %        const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
00765 %        const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
00766 %
00767 %  A description of each parameter follows:
00768 %
00769 %    o cache_view: the cache view.
00770 %
00771 %    o virtual_pixel_method: the virtual pixel method.
00772 %
00773 %    o x,y:  These values define the offset of the pixel.
00774 %
00775 %    o pixel: return a pixel at the specified (x,y) location.
00776 %
00777 %    o exception: return any errors or warnings in this structure.
00778 %
00779 */
00780 MagickExport MagickBooleanType GetOneCacheViewVirtualMethodPixel(
00781   const CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method,
00782   const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
00783 {
00784   const int
00785     id = GetOpenMPThreadId();
00786 
00787   const Quantum
00788     *p;
00789 
00790   register ssize_t
00791     i;
00792 
00793   assert(cache_view != (CacheView *) NULL);
00794   assert(cache_view->signature == MagickSignature);
00795   assert(id < (int) cache_view->number_threads);
00796   (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
00797   p=GetVirtualPixelsFromNexus(cache_view->image,virtual_pixel_method,x,y,1,1,
00798     cache_view->nexus_info[id],exception);
00799   if (p == (const Quantum *) NULL)
00800     {
00801       PixelInfo
00802         background_color;
00803 
00804       background_color=cache_view->image->background_color;
00805       pixel[RedPixelChannel]=ClampToQuantum(background_color.red);
00806       pixel[GreenPixelChannel]=ClampToQuantum(background_color.green);
00807       pixel[BluePixelChannel]=ClampToQuantum(background_color.blue);
00808       pixel[BlackPixelChannel]=ClampToQuantum(background_color.black);
00809       pixel[AlphaPixelChannel]=ClampToQuantum(background_color.alpha);
00810       return(MagickFalse);
00811     }
00812   for (i=0; i < (ssize_t) GetPixelChannels(cache_view->image); i++)
00813   {
00814     PixelChannel
00815       channel;
00816 
00817     channel=GetPixelChannelMapChannel(cache_view->image,i);
00818     pixel[channel]=p[i];
00819   }
00820   return(MagickTrue);
00821 }
00822 
00823 /*
00824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00825 %                                                                             %
00826 %                                                                             %
00827 %                                                                             %
00828 %   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                 %
00829 %                                                                             %
00830 %                                                                             %
00831 %                                                                             %
00832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00833 %
00834 %  QueueCacheViewAuthenticPixels() queues authentic pixels from the in-memory or
00835 %  disk pixel cache as defined by the geometry parameters.   A pointer to the
00836 %  pixels is returned if the pixels are transferred, otherwise a NULL is
00837 %  returned.
00838 %
00839 %  The format of the QueueCacheViewAuthenticPixels method is:
00840 %
00841 %      Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
00842 %        const ssize_t x,const ssize_t y,const size_t columns,
00843 %        const size_t rows,ExceptionInfo *exception)
00844 %
00845 %  A description of each parameter follows:
00846 %
00847 %    o cache_view: the cache view.
00848 %
00849 %    o x,y,columns,rows:  These values define the perimeter of a region of
00850 %      pixels.
00851 %
00852 %    o exception: return any errors or warnings in this structure.
00853 %
00854 */
00855 MagickExport Quantum *QueueCacheViewAuthenticPixels(CacheView *cache_view,
00856   const ssize_t x,const ssize_t y,const size_t columns,const size_t rows,
00857   ExceptionInfo *exception)
00858 {
00859   const int
00860     id = GetOpenMPThreadId();
00861 
00862   Quantum
00863     *pixels;
00864 
00865   assert(cache_view != (CacheView *) NULL);
00866   assert(cache_view->signature == MagickSignature);
00867   assert(id < (int) cache_view->number_threads);
00868   pixels=QueueAuthenticPixelCacheNexus(cache_view->image,x,y,columns,rows,
00869     MagickFalse,cache_view->nexus_info[id],exception);
00870   return(pixels);
00871 }
00872 
00873 /*
00874 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00875 %                                                                             %
00876 %                                                                             %
00877 %                                                                             %
00878 %   S e t C a c h e V i e w S t o r a g e C l a s s                           %
00879 %                                                                             %
00880 %                                                                             %
00881 %                                                                             %
00882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00883 %
00884 %  SetCacheViewStorageClass() sets the image storage class associated with
00885 %  the specified view.
00886 %
00887 %  The format of the SetCacheViewStorageClass method is:
00888 %
00889 %      MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
00890 %        const ClassType storage_class,ExceptionInfo *exception)
00891 %
00892 %  A description of each parameter follows:
00893 %
00894 %    o cache_view: the cache view.
00895 %
00896 %    o storage_class: the image storage class: PseudoClass or DirectClass.
00897 %
00898 %    o exception: return any errors or warnings in this structure.
00899 %
00900 */
00901 MagickExport MagickBooleanType SetCacheViewStorageClass(CacheView *cache_view,
00902   const ClassType storage_class,ExceptionInfo *exception)
00903 {
00904   assert(cache_view != (CacheView *) NULL);
00905   assert(cache_view->signature == MagickSignature);
00906   if (cache_view->debug != MagickFalse)
00907     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00908       cache_view->image->filename);
00909   return(SetImageStorageClass(cache_view->image,storage_class,exception));
00910 }
00911 
00912 /*
00913 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00914 %                                                                             %
00915 %                                                                             %
00916 %                                                                             %
00917 %   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               %
00918 %                                                                             %
00919 %                                                                             %
00920 %                                                                             %
00921 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00922 %
00923 %  SetCacheViewVirtualPixelMethod() sets the virtual pixel method associated
00924 %  with the specified cache view.
00925 %
00926 %  The format of the SetCacheViewVirtualPixelMethod method is:
00927 %
00928 %      MagickBooleanType SetCacheViewVirtualPixelMethod(CacheView *cache_view,
00929 %        const VirtualPixelMethod virtual_pixel_method)
00930 %
00931 %  A description of each parameter follows:
00932 %
00933 %    o cache_view: the cache view.
00934 %
00935 %    o virtual_pixel_method: the virtual pixel method.
00936 %
00937 */
00938 MagickExport MagickBooleanType SetCacheViewVirtualPixelMethod(
00939   CacheView *cache_view,const VirtualPixelMethod virtual_pixel_method)
00940 {
00941   assert(cache_view != (CacheView *) NULL);
00942   assert(cache_view->signature == MagickSignature);
00943   if (cache_view->debug != MagickFalse)
00944     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00945       cache_view->image->filename);
00946   cache_view->virtual_pixel_method=virtual_pixel_method;
00947   return(MagickTrue);
00948 }
00949 
00950 /*
00951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00952 %                                                                             %
00953 %                                                                             %
00954 %                                                                             %
00955 %   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                   %
00956 %                                                                             %
00957 %                                                                             %
00958 %                                                                             %
00959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00960 %
00961 %  SyncCacheViewAuthenticPixels() saves the cache view pixels to the in-memory
00962 %  or disk cache.  It returns MagickTrue if the pixel region is flushed,
00963 %  otherwise MagickFalse.
00964 %
00965 %  The format of the SyncCacheViewAuthenticPixels method is:
00966 %
00967 %      MagickBooleanType SyncCacheViewAuthenticPixels(CacheView *cache_view,
00968 %        ExceptionInfo *exception)
00969 %
00970 %  A description of each parameter follows:
00971 %
00972 %    o cache_view: the cache view.
00973 %
00974 %    o exception: return any errors or warnings in this structure.
00975 %
00976 */
00977 MagickExport MagickBooleanType SyncCacheViewAuthenticPixels(
00978   CacheView *cache_view,ExceptionInfo *exception)
00979 {
00980   const int
00981     id = GetOpenMPThreadId();
00982 
00983   MagickBooleanType
00984     status;
00985 
00986   assert(cache_view != (CacheView *) NULL);
00987   assert(cache_view->signature == MagickSignature);
00988   assert(id < (int) cache_view->number_threads);
00989   status=SyncAuthenticPixelCacheNexus(cache_view->image,
00990     cache_view->nexus_info[id],exception);
00991   return(status);
00992 }