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

Generated on 19 Nov 2009 for MagickCore by  doxygen 1.6.1