deprecate.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %        DDDD   EEEEE  PPPP   RRRR   EEEEE   CCCC   AAA   TTTTT  EEEEE        %
00007 %        D   D  E      P   P  R   R  E      C      A   A    T    E            %
00008 %        D   D  EEE    PPPPP  RRRR   EEE    C      AAAAA    T    EEE          %
00009 %        D   D  E      P      R R    E      C      A   A    T    E            %
00010 %        DDDD   EEEEE  P      R  R   EEEEE   CCCC  A   A    T    EEEEE        %
00011 %                                                                             %
00012 %                                                                             %
00013 %                        MagickCore Deprecated Methods                        %
00014 %                                                                             %
00015 %                              Software Design                                %
00016 %                                John Cristy                                  %
00017 %                                October 2002                                 %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
00021 %  dedicated to making software imaging solutions freely available.           %
00022 %                                                                             %
00023 %  You may not use this file except in compliance with the License.  You may  %
00024 %  obtain a copy of the License at                                            %
00025 %                                                                             %
00026 %    http://www.imagemagick.org/script/license.php                            %
00027 %                                                                             %
00028 %  Unless required by applicable law or agreed to in writing, software        %
00029 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00030 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00031 %  See the License for the specific language governing permissions and        %
00032 %  limitations under the License.                                             %
00033 %                                                                             %
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 %
00036 %
00037 %
00038 */
00039 
00040 /*
00041   Include declarations.
00042 */
00043 #include "magick/studio.h"
00044 #include "magick/property.h"
00045 #include "magick/blob.h"
00046 #include "magick/blob-private.h"
00047 #include "magick/cache.h"
00048 #include "magick/cache-view.h"
00049 #include "magick/client.h"
00050 #include "magick/color.h"
00051 #include "magick/color-private.h"
00052 #include "magick/colorspace.h"
00053 #include "magick/composite.h"
00054 #include "magick/composite-private.h"
00055 #include "magick/constitute.h"
00056 #include "magick/deprecate.h"
00057 #include "magick/draw.h"
00058 #include "magick/draw-private.h"
00059 #include "magick/effect.h"
00060 #include "magick/exception.h"
00061 #include "magick/exception-private.h"
00062 #include "magick/geometry.h"
00063 #include "magick/identify.h"
00064 #include "magick/image.h"
00065 #include "magick/image-private.h"
00066 #include "magick/list.h"
00067 #include "magick/log.h"
00068 #include "magick/memory_.h"
00069 #include "magick/magick.h"
00070 #include "magick/monitor.h"
00071 #include "magick/monitor-private.h"
00072 #include "magick/paint.h"
00073 #include "magick/pixel.h"
00074 #include "magick/pixel-private.h"
00075 #include "magick/quantize.h"
00076 #include "magick/random_.h"
00077 #include "magick/resource_.h"
00078 #include "magick/semaphore.h"
00079 #include "magick/segment.h"
00080 #include "magick/splay-tree.h"
00081 #include "magick/string_.h"
00082 #include "magick/threshold.h"
00083 #include "magick/transform.h"
00084 #include "magick/utility.h"
00085 
00086 #if !defined(MAGICKCORE_EXCLUDE_DEPRECATED)
00087 /*
00088   Global declarations.
00089 */
00090 static MonitorHandler
00091   monitor_handler = (MonitorHandler) NULL;
00092 
00093 /*
00094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00095 %                                                                             %
00096 %                                                                             %
00097 %                                                                             %
00098 %   A c q u i r e C a c h e V i e w I n d e x e s                             %
00099 %                                                                             %
00100 %                                                                             %
00101 %                                                                             %
00102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00103 %
00104 %  AcquireCacheViewIndexes() returns the indexes associated with the specified
00105 %  view.
00106 %
00107 %  The format of the AcquireCacheViewIndexes method is:
00108 %
00109 %      const IndexPacket *AcquireCacheViewIndexes(const ViewInfo *cache_view)
00110 %
00111 %  A description of each parameter follows:
00112 %
00113 %    o cache_view: the cache view.
00114 %
00115 */
00116 MagickExport const IndexPacket *AcquireCacheViewIndexes(
00117   const ViewInfo *cache_view)
00118 {
00119   return(GetCacheViewVirtualIndexQueue(cache_view));
00120 }
00121 
00122 /*
00123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00124 %                                                                             %
00125 %                                                                             %
00126 %                                                                             %
00127 %   A c q u i r e C a c h e V i e w P i x e l s                               %
00128 %                                                                             %
00129 %                                                                             %
00130 %                                                                             %
00131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00132 %
00133 %  AcquireCacheViewPixels() gets pixels from the in-memory or disk pixel cache
00134 %  as defined by the geometry parameters.   A pointer to the pixels is returned
00135 %  if the pixels are transferred, otherwise a NULL is returned.
00136 %
00137 %  The format of the AcquireCacheViewPixels method is:
00138 %
00139 %      const PixelPacket *AcquireCacheViewPixels(const ViewInfo *cache_view,
00140 %        const long x,const long y,const unsigned long columns,
00141 %        const unsigned long rows,ExceptionInfo *exception)
00142 %
00143 %  A description of each parameter follows:
00144 %
00145 %    o cache_view: the cache view.
00146 %
00147 %    o x,y,columns,rows:  These values define the perimeter of a region of
00148 %      pixels.
00149 %
00150 %    o exception: return any errors or warnings in this structure.
00151 %
00152 */
00153 MagickExport const PixelPacket *AcquireCacheViewPixels(
00154   const ViewInfo *cache_view,const long x,const long y,
00155   const unsigned long columns,const unsigned long rows,ExceptionInfo *exception)
00156 {
00157   return(GetCacheViewVirtualPixels(cache_view,x,y,columns,rows,exception));
00158 }
00159 
00160 /*
00161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00162 %                                                                             %
00163 %                                                                             %
00164 %                                                                             %
00165 %   A c q u i r e I m a g e P i x e l s                                        %
00166 %                                                                             %
00167 %                                                                             %
00168 %                                                                             %
00169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00170 %
00171 %  AcquireImagePixels() returns an immutable pixel region. If the
00172 %  region is successfully accessed, a pointer to it is returned, otherwise
00173 %  NULL is returned. The returned pointer may point to a temporary working
00174 %  copy of the pixels or it may point to the original pixels in memory.
00175 %  Performance is maximized if the selected region is part of one row, or one
00176 %  or more full rows, since there is opportunity to access the pixels in-place
00177 %  (without a copy) if the image is in RAM, or in a memory-mapped file.  The
00178 %  returned pointer should *never* be deallocated by the user.
00179 %
00180 %  Pixels accessed via the returned pointer represent a simple array of type
00181 %  PixelPacket.  If the image type is CMYK or the storage class is PseudoClass,
00182 %  call GetAuthenticIndexQueue() after invoking GetAuthenticPixels() to access the
00183 %  black color component or to obtain the colormap indexes (of type IndexPacket)
00184 %  corresponding to the region.
00185 %
00186 %  If you plan to modify the pixels, use GetAuthenticPixels() instead.
00187 %
00188 %  Note, the AcquireImagePixels() and GetAuthenticPixels() methods are not
00189 %  thread-safe.  In a threaded environment, use GetCacheViewVirtualPixels() or
00190 %  GetCacheViewAuthenticPixels() instead.
00191 %
00192 %  The format of the AcquireImagePixels() method is:
00193 %
00194 %      const PixelPacket *AcquireImagePixels(const Image *image,const long x,
00195 %        const long y,const unsigned long columns,const unsigned long rows,
00196 %        ExceptionInfo *exception)
00197 %
00198 %  A description of each parameter follows:
00199 %
00200 %    o image: the image.
00201 %
00202 %    o x,y,columns,rows:  These values define the perimeter of a region of
00203 %      pixels.
00204 %
00205 %    o exception: return any errors or warnings in this structure.
00206 %
00207 */
00208 MagickExport const PixelPacket *AcquireImagePixels(const Image *image,
00209   const long x,const long y,const unsigned long columns,
00210   const unsigned long rows,ExceptionInfo *exception)
00211 {
00212   return(GetVirtualPixels(image,x,y,columns,rows,exception));
00213 }
00214 
00215 /*
00216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00217 %                                                                             %
00218 %                                                                             %
00219 %                                                                             %
00220 %   A c q u i r e I n d e x e s                                               %
00221 %                                                                             %
00222 %                                                                             %
00223 %                                                                             %
00224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00225 %
00226 %  AcquireIndexes() returns the black channel or the colormap indexes
00227 %  associated with the last call to QueueAuthenticPixels() or GetVirtualPixels().
00228 %  NULL is returned if the black channel or colormap indexes are not available.
00229 %
00230 %  The format of the AcquireIndexes() method is:
00231 %
00232 %      const IndexPacket *AcquireIndexes(const Image *image)
00233 %
00234 %  A description of each parameter follows:
00235 %
00236 %    o indexes: AcquireIndexes() returns the indexes associated with the last
00237 %      call to QueueAuthenticPixels() or GetVirtualPixels().
00238 %
00239 %    o image: the image.
00240 %
00241 */
00242 MagickExport const IndexPacket *AcquireIndexes(const Image *image)
00243 {
00244   return(GetVirtualIndexQueue(image));
00245 }
00246 
00247 /*
00248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00249 %                                                                             %
00250 %                                                                             %
00251 %                                                                             %
00252 %   A c q u i r e M e m o r y                                                 %
00253 %                                                                             %
00254 %                                                                             %
00255 %                                                                             %
00256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00257 %
00258 %  AcquireMemory() returns a pointer to a block of memory at least size bytes
00259 %  suitably aligned for any use.
00260 %
00261 %  The format of the AcquireMemory method is:
00262 %
00263 %      void *AcquireMemory(const size_t size)
00264 %
00265 %  A description of each parameter follows:
00266 %
00267 %    o size: the size of the memory in bytes to allocate.
00268 %
00269 */
00270 MagickExport void *AcquireMemory(const size_t size)
00271 {
00272   void
00273     *allocation;
00274 
00275   assert(size != 0);
00276   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
00277   allocation=malloc(size);
00278   return(allocation);
00279 }
00280 
00281 /*
00282 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00283 %                                                                             %
00284 %                                                                             %
00285 %                                                                             %
00286 %   A c q u i r e O n e C a c h e V i e w P i x e l                           %
00287 %                                                                             %
00288 %                                                                             %
00289 %                                                                             %
00290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00291 %
00292 %  AcquireOneCacheViewPixel() returns a single pixel at the specified (x,y)
00293 %  location.  The image background color is returned if an error occurs.  If
00294 %  you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
00295 %
00296 %  The format of the AcquireOneCacheViewPixel method is:
00297 %
00298 %      MagickBooleanType AcquireOneCacheViewPixel(const ViewInfo *cache_view,
00299 %        const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
00300 %
00301 %  A description of each parameter follows:
00302 %
00303 %    o cache_view: the cache view.
00304 %
00305 %    o x,y:  These values define the offset of the pixel.
00306 %
00307 %    o pixel: return a pixel at the specified (x,y) location.
00308 %
00309 %    o exception: return any errors or warnings in this structure.
00310 %
00311 */
00312 MagickExport MagickBooleanType AcquireOneCacheViewPixel(
00313   const ViewInfo *cache_view,const long x,const long y,PixelPacket *pixel,
00314   ExceptionInfo *exception)
00315 {
00316   return(GetOneCacheViewVirtualPixel(cache_view,x,y,pixel,exception));
00317 }
00318 
00319 /*
00320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00321 %                                                                             %
00322 %                                                                             %
00323 %                                                                             %
00324 %   A c q u i r e O n e C a c h e V i e w V i r t u a l P i x e l             %
00325 %                                                                             %
00326 %                                                                             %
00327 %                                                                             %
00328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00329 %
00330 %  AcquireOneCacheViewVirtualPixel() returns a single pixel at the specified
00331 %  (x,y) location.  The image background color is returned if an error occurs.
00332 %  If you plan to modify the pixel, use GetOneCacheViewAuthenticPixel() instead.
00333 %
00334 %  The format of the AcquireOneCacheViewPixel method is:
00335 %
00336 %      MagickBooleanType AcquireOneCacheViewVirtualPixel(
00337 %        const ViewInfo *cache_view,
00338 %        const VirtualPixelMethod virtual_pixel_method,const long x,
00339 %        const long y,PixelPacket *pixel,ExceptionInfo *exception)
00340 %
00341 %  A description of each parameter follows:
00342 %
00343 %    o cache_view: the cache view.
00344 %
00345 %    o virtual_pixel_method: the virtual pixel method.
00346 %
00347 %    o x,y:  These values define the offset of the pixel.
00348 %
00349 %    o pixel: return a pixel at the specified (x,y) location.
00350 %
00351 %    o exception: return any errors or warnings in this structure.
00352 %
00353 */
00354 MagickExport MagickBooleanType AcquireOneCacheViewVirtualPixel(
00355   const ViewInfo *cache_view,const VirtualPixelMethod virtual_pixel_method,
00356   const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
00357 {
00358   MagickBooleanType
00359     status;
00360 
00361   status=GetOneCacheViewVirtualMethodPixel(cache_view,virtual_pixel_method,
00362     x,y,pixel,exception);
00363   return(status);
00364 }
00365 
00366 /*
00367 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00368 %                                                                             %
00369 %                                                                             %
00370 %                                                                             %
00371 %   A c q u i r e O n e M a g i c k P i x e l                                 %
00372 %                                                                             %
00373 %                                                                             %
00374 %                                                                             %
00375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00376 %
00377 %  AcquireOneMagickPixel() returns a single pixel at the specified (x,y)
00378 %  location.  The image background color is returned if an error occurs.  If
00379 %  you plan to modify the pixel, use GetOnePixel() instead.
00380 %
00381 %  The format of the AcquireOneMagickPixel() method is:
00382 %
00383 %      MagickPixelPacket AcquireOneMagickPixel(const Image image,const long x,
00384 %        const long y,ExceptionInfo exception)
00385 %
00386 %  A description of each parameter follows:
00387 %
00388 %    o image: the image.
00389 %
00390 %    o x,y:  These values define the location of the pixel to return.
00391 %
00392 %    o exception: return any errors or warnings in this structure.
00393 %
00394 */
00395 MagickExport MagickPixelPacket AcquireOneMagickPixel(const Image *image,
00396   const long x,const long y,ExceptionInfo *exception)
00397 {
00398   MagickPixelPacket
00399     pixel;
00400 
00401   (void) GetOneVirtualMagickPixel(image,x,y,&pixel,exception);
00402   return(pixel);
00403 }
00404 
00405 /*
00406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00407 %                                                                             %
00408 %                                                                             %
00409 %                                                                             %
00410 %   A c q u i r e O n e P i x e l                                             %
00411 %                                                                             %
00412 %                                                                             %
00413 %                                                                             %
00414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00415 %
00416 %  AcquireOnePixel() returns a single pixel at the specified (x,y) location.
00417 %  The image background color is returned if an error occurs.  If you plan to
00418 %  modify the pixel, use GetOnePixel() instead.
00419 %
00420 %  The format of the AcquireOnePixel() method is:
00421 %
00422 %      PixelPacket AcquireOnePixel(const Image image,const long x,
00423 %        const long y,ExceptionInfo exception)
00424 %
00425 %  A description of each parameter follows:
00426 %
00427 %    o image: the image.
00428 %
00429 %    o x,y:  These values define the location of the pixel to return.
00430 %
00431 %    o exception: return any errors or warnings in this structure.
00432 %
00433 */
00434 MagickExport PixelPacket AcquireOnePixel(const Image *image,const long x,
00435   const long y,ExceptionInfo *exception)
00436 {
00437   PixelPacket
00438     pixel;
00439 
00440   (void) GetOneVirtualPixel(image,x,y,&pixel,exception);
00441   return(pixel);
00442 }
00443 
00444 /*
00445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00446 %                                                                             %
00447 %                                                                             %
00448 %                                                                             %
00449 %   A c q u i r e O n e V i r t u a l P i x e l                               %
00450 %                                                                             %
00451 %                                                                             %
00452 %                                                                             %
00453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00454 %
00455 %  AcquireOneVirtualPixel() returns a single pixel at the specified (x,y)
00456 %  location as defined by specified pixel method.  The image background color
00457 %  is returned if an error occurs.  If you plan to modify the pixel, use
00458 %  GetOnePixel() instead.
00459 %
00460 %  The format of the AcquireOneVirtualPixel() method is:
00461 %
00462 %      PixelPacket AcquireOneVirtualPixel(const Image image,
00463 %        const VirtualPixelMethod virtual_pixel_method,const long x,
00464 %        const long y,ExceptionInfo exception)
00465 %
00466 %  A description of each parameter follows:
00467 %
00468 %    o virtual_pixel_method: the virtual pixel method.
00469 %
00470 %    o image: the image.
00471 %
00472 %    o x,y:  These values define the location of the pixel to return.
00473 %
00474 %    o exception: return any errors or warnings in this structure.
00475 %
00476 */
00477 MagickExport PixelPacket AcquireOneVirtualPixel(const Image *image,
00478   const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
00479   ExceptionInfo *exception)
00480 {
00481   PixelPacket
00482     pixel;
00483 
00484   (void) GetOneVirtualMethodPixel(image,virtual_pixel_method,x,y,&pixel,
00485     exception);
00486   return(pixel);
00487 }
00488 
00489 /*
00490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00491 %                                                                             %
00492 %                                                                             %
00493 %                                                                             %
00494 %   A c q u i r e P i x e l s                                                 %
00495 %                                                                             %
00496 %                                                                             %
00497 %                                                                             %
00498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00499 %
00500 %  AcquirePixels() returns the pixels associated with the last call to
00501 %  QueueAuthenticPixels() or GetVirtualPixels().
00502 %
00503 %  The format of the AcquirePixels() method is:
00504 %
00505 %      const PixelPacket *AcquirePixels(const Image image)
00506 %
00507 %  A description of each parameter follows:
00508 %
00509 %    o image: the image.
00510 %
00511 */
00512 MagickExport const PixelPacket *AcquirePixels(const Image *image)
00513 {
00514   return(GetVirtualPixelQueue(image));
00515 }
00516 
00517 /*
00518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00519 %                                                                             %
00520 %                                                                             %
00521 %                                                                             %
00522 %   A f f i n i t y I m a g e                                                 %
00523 %                                                                             %
00524 %                                                                             %
00525 %                                                                             %
00526 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00527 %
00528 %  AffinityImage() replaces the colors of an image with the closest color from
00529 %  a reference image.
00530 %
00531 %  The format of the AffinityImage method is:
00532 %
00533 %      MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
00534 %        Image *image,const Image *affinity_image)
00535 %
00536 %  A description of each parameter follows:
00537 %
00538 %    o quantize_info: Specifies a pointer to an QuantizeInfo structure.
00539 %
00540 %    o image: the image.
00541 %
00542 %    o affinity_image: the reference image.
00543 %
00544 */
00545 MagickExport MagickBooleanType AffinityImage(const QuantizeInfo *quantize_info,
00546   Image *image,const Image *affinity_image)
00547 {
00548   return(RemapImage(quantize_info,image,affinity_image));
00549 }
00550 
00551 /*
00552 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00553 %                                                                             %
00554 %                                                                             %
00555 %                                                                             %
00556 %   A f f i n i t y I m a g e s                                               %
00557 %                                                                             %
00558 %                                                                             %
00559 %                                                                             %
00560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00561 %
00562 %  AffinityImages() replaces the colors of a sequence of images with the
00563 %  closest color from a reference image.
00564 %
00565 %  The format of the AffinityImage method is:
00566 %
00567 %      MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
00568 %        Image *images,Image *affinity_image)
00569 %
00570 %  A description of each parameter follows:
00571 %
00572 %    o quantize_info: Specifies a pointer to an QuantizeInfo structure.
00573 %
00574 %    o images: the image sequence.
00575 %
00576 %    o affinity_image: the reference image.
00577 %
00578 */
00579 MagickExport MagickBooleanType AffinityImages(const QuantizeInfo *quantize_info,
00580   Image *images,const Image *affinity_image)
00581 {
00582   return(RemapImages(quantize_info,images,affinity_image));
00583 }
00584 
00585 /*
00586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00587 %                                                                             %
00588 %                                                                             %
00589 %                                                                             %
00590 %   A l l o c a t e I m a g e                                                 %
00591 %                                                                             %
00592 %                                                                             %
00593 %                                                                             %
00594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00595 %
00596 %  AllocateImage() returns a pointer to an image structure initialized to
00597 %  default values.
00598 %
00599 %  The format of the AllocateImage method is:
00600 %
00601 %      Image *AllocateImage(const ImageInfo *image_info)
00602 %
00603 %  A description of each parameter follows:
00604 %
00605 %    o image_info: Many of the image default values are set from this
00606 %      structure.  For example, filename, compression, depth, background color,
00607 %      and others.
00608 %
00609 */
00610 MagickExport Image *AllocateImage(const ImageInfo *image_info)
00611 {
00612   return(AcquireImage(image_info));
00613 }
00614 
00615 /*
00616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00617 %                                                                             %
00618 %                                                                             %
00619 %                                                                             %
00620 %   A l l o c a t e I m a g e C o l o r m a p                                 %
00621 %                                                                             %
00622 %                                                                             %
00623 %                                                                             %
00624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00625 %
00626 %  AllocateImageColormap() allocates an image colormap and initializes
00627 %  it to a linear gray colorspace.  If the image already has a colormap,
00628 %  it is replaced.  AllocateImageColormap() returns MagickTrue if successful,
00629 %  otherwise MagickFalse if there is not enough memory.
00630 %
00631 %  The format of the AllocateImageColormap method is:
00632 %
00633 %      MagickBooleanType AllocateImageColormap(Image *image,
00634 %        const unsigned long colors)
00635 %
00636 %  A description of each parameter follows:
00637 %
00638 %    o image: the image.
00639 %
00640 %    o colors: the number of colors in the image colormap.
00641 %
00642 */
00643 MagickExport MagickBooleanType AllocateImageColormap(Image *image,
00644   const unsigned long colors)
00645 {
00646   return(AcquireImageColormap(image,colors));
00647 }
00648 
00649 /*
00650 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00651 %                                                                             %
00652 %                                                                             %
00653 %                                                                             %
00654 %   A l l o c a t e N e x t I m a g e                                         %
00655 %                                                                             %
00656 %                                                                             %
00657 %                                                                             %
00658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00659 %
00660 %  AllocateNextImage() initializes the next image in a sequence to
00661 %  default values.  The next member of image points to the newly allocated
00662 %  image.  If there is a memory shortage, next is assigned NULL.
00663 %
00664 %  The format of the AllocateNextImage method is:
00665 %
00666 %      void AllocateNextImage(const ImageInfo *image_info,Image *image)
00667 %
00668 %  A description of each parameter follows:
00669 %
00670 %    o image_info: Many of the image default values are set from this
00671 %      structure.  For example, filename, compression, depth, background color,
00672 %      and others.
00673 %
00674 %    o image: the image.
00675 %
00676 */
00677 MagickExport void AllocateNextImage(const ImageInfo *image_info,Image *image)
00678 {
00679   AcquireNextImage(image_info,image);
00680 }
00681 
00682 /*
00683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00684 %                                                                             %
00685 %                                                                             %
00686 %                                                                             %
00687 %   A c q u i r e S t r i n g                                                 %
00688 %                                                                             %
00689 %                                                                             %
00690 %                                                                             %
00691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00692 %
00693 %  AllocateString() allocates memory for a string and copies the source string
00694 %  to that memory location (and returns it).
00695 %
00696 %  The format of the AllocateString method is:
00697 %
00698 %      char *AllocateString(const char *source)
00699 %
00700 %  A description of each parameter follows:
00701 %
00702 %    o source: A character string.
00703 %
00704 */
00705 MagickExport char *AllocateString(const char *source)
00706 {
00707   char
00708     *destination;
00709 
00710   size_t
00711     length;
00712 
00713   assert(source != (const char *) NULL);
00714   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
00715   length=strlen(source)+MaxTextExtent+1;
00716   destination=(char *) AcquireQuantumMemory(length,sizeof(*destination));
00717   if (destination == (char *) NULL)
00718     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00719   *destination='\0';
00720   if (source != (char *) NULL)
00721     (void) CopyMagickString(destination,source,length);
00722   return(destination);
00723 }
00724 
00725 /*
00726 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00727 %                                                                             %
00728 %                                                                             %
00729 %                                                                             %
00730 %     C h a n n e l I m a g e                                                 %
00731 %                                                                             %
00732 %                                                                             %
00733 %                                                                             %
00734 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00735 %
00736 %  Extract a channel from the image.  A channel is a particular color component
00737 %  of each pixel in the image.
00738 %
00739 %  The format of the ChannelImage method is:
00740 %
00741 %      unsigned int ChannelImage(Image *image,const ChannelType channel)
00742 %
00743 %  A description of each parameter follows:
00744 %
00745 %    o image: the image.
00746 %
00747 %    o channel: Identify which channel to extract: RedChannel, GreenChannel,
00748 %      BlueChannel, OpacityChannel, CyanChannel, MagentaChannel, YellowChannel,
00749 %      or BlackChannel.
00750 %
00751 */
00752 MagickExport unsigned int ChannelImage(Image *image,const ChannelType channel)
00753 {
00754   return(SeparateImageChannel(image,channel));
00755 }
00756 
00757 /*
00758 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00759 %                                                                             %
00760 %                                                                             %
00761 %                                                                             %
00762 %     C h a n n e l T h r e s h o l d I m a g e                               %
00763 %                                                                             %
00764 %                                                                             %
00765 %                                                                             %
00766 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00767 %
00768 %  ChannelThresholdImage() changes the value of individual pixels based on
00769 %  the intensity of each pixel channel.  The result is a high-contrast image.
00770 %
00771 %  The format of the ChannelThresholdImage method is:
00772 %
00773 %      unsigned int ChannelThresholdImage(Image *image,const char *level)
00774 %
00775 %  A description of each parameter follows:
00776 %
00777 %    o image: the image.
00778 %
00779 %    o level: define the threshold values.
00780 %
00781 */
00782 MagickExport unsigned int ChannelThresholdImage(Image *image,const char *level)
00783 {
00784   MagickPixelPacket
00785     threshold;
00786 
00787   GeometryInfo
00788     geometry_info;
00789 
00790   unsigned int
00791     flags,
00792     status;
00793 
00794   assert(image != (Image *) NULL);
00795   assert(image->signature == MagickSignature);
00796   if (image->debug != MagickFalse)
00797     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00798   if (image->debug != MagickFalse)
00799     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
00800   if (level == (char *) NULL)
00801     return(MagickFalse);
00802   flags=ParseGeometry(level,&geometry_info);
00803   threshold.red=geometry_info.rho;
00804   threshold.green=geometry_info.sigma;
00805   if ((flags & SigmaValue) == 0)
00806     threshold.green=threshold.red;
00807   threshold.blue=geometry_info.xi;
00808   if ((flags & XiValue) == 0)
00809     threshold.blue=threshold.red;
00810   status=BilevelImageChannel(image,RedChannel,threshold.red);
00811   status|=BilevelImageChannel(image,GreenChannel,threshold.green);
00812   status|=BilevelImageChannel(image,BlueChannel,threshold.blue);
00813   return(status);
00814 }
00815 
00816 /*
00817 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00818 %                                                                             %
00819 %                                                                             %
00820 %                                                                             %
00821 %   C l i p I m a g e P a t h                                                 %
00822 %                                                                             %
00823 %                                                                             %
00824 %                                                                             %
00825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00826 %
00827 %  ClipPathImage() sets the image clip mask based any clipping path information
00828 %  if it exists.
00829 %
00830 %  The format of the ClipImage method is:
00831 %
00832 %      MagickBooleanType ClipPathImage(Image *image,const char *pathname,
00833 %        const MagickBooleanType inside)
00834 %
00835 %  A description of each parameter follows:
00836 %
00837 %    o image: the image.
00838 %
00839 %    o pathname: name of clipping path resource. If name is preceded by #, use
00840 %      clipping path numbered by name.
00841 %
00842 %    o inside: if non-zero, later operations take effect inside clipping path.
00843 %      Otherwise later operations take effect outside clipping path.
00844 %
00845 */
00846 MagickExport MagickBooleanType ClipPathImage(Image *image,const char *pathname,
00847   const MagickBooleanType inside)
00848 {
00849   return(ClipImagePath(image,pathname,inside));
00850 }
00851 
00852 /*
00853 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00854 %                                                                             %
00855 %                                                                             %
00856 %                                                                             %
00857 %   C l o n e I m a g e A t t r i b u t e s                                   %
00858 %                                                                             %
00859 %                                                                             %
00860 %                                                                             %
00861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00862 %
00863 %  CloneImageAttributes() clones one or more image attributes.
00864 %
00865 %  The format of the CloneImageAttributes method is:
00866 %
00867 %      MagickBooleanType CloneImageAttributes(Image *image,
00868 %        const Image *clone_image)
00869 %
00870 %  A description of each parameter follows:
00871 %
00872 %    o image: the image.
00873 %
00874 %    o clone_image: the clone image.
00875 %
00876 */
00877 MagickExport MagickBooleanType CloneImageAttributes(Image *image,
00878   const Image *clone_image)
00879 {
00880   return(CloneImageProperties(image,clone_image));
00881 }
00882 
00883 /*
00884 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00885 %                                                                             %
00886 %                                                                             %
00887 %                                                                             %
00888 %   C l o n e M e m o r y                                                     %
00889 %                                                                             %
00890 %                                                                             %
00891 %                                                                             %
00892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00893 %
00894 %  CloneMemory() copies size bytes from memory area source to the destination.
00895 %  Copying between objects that overlap will take place correctly.  It returns
00896 %  destination.
00897 %
00898 %  The format of the CloneMemory method is:
00899 %
00900 %      void *CloneMemory(void *destination,const void *source,
00901 %        const size_t size)
00902 %
00903 %  A description of each parameter follows:
00904 %
00905 %    o destination: the destination.
00906 %
00907 %    o source: the source.
00908 %
00909 %    o size: the size of the memory in bytes to allocate.
00910 %
00911 */
00912 MagickExport void *CloneMemory(void *destination,const void *source,
00913   const size_t size)
00914 {
00915   register const unsigned char
00916     *p;
00917 
00918   register unsigned char
00919     *q;
00920 
00921   register long
00922     i;
00923 
00924   assert(destination != (void *) NULL);
00925   assert(source != (const void *) NULL);
00926   (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),"last use: v5.5.7");
00927   p=(const unsigned char *) source;
00928   q=(unsigned char *) destination;
00929   if ((p <= q) || ((p+size) >= q))
00930     return(CopyMagickMemory(destination,source,size));
00931   /*
00932     Overlap, copy backwards.
00933   */
00934   p+=size;
00935   q+=size;
00936   for (i=(long) (size-1); i >= 0; i--)
00937     *--q=(*--p);
00938   return(destination);
00939 }
00940 
00941 /*
00942 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00943 %                                                                             %
00944 %                                                                             %
00945 %                                                                             %
00946 %   C l o s e C a c h e V i e w                                               %
00947 %                                                                             %
00948 %                                                                             %
00949 %                                                                             %
00950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00951 %
00952 %  CloseCacheView() closes the specified view returned by a previous call to
00953 %  OpenCacheView().
00954 %
00955 %  The format of the CloseCacheView method is:
00956 %
00957 %      ViewInfo *CloseCacheView(ViewInfo *view_info)
00958 %
00959 %  A description of each parameter follows:
00960 %
00961 %    o view_info: the address of a structure of type ViewInfo.
00962 %
00963 */
00964 MagickExport ViewInfo *CloseCacheView(ViewInfo *view_info)
00965 {
00966   return(DestroyCacheView(view_info));
00967 }
00968 
00969 /*
00970 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00971 %                                                                             %
00972 %                                                                             %
00973 %                                                                             %
00974 %   C o l o r F l o o d f i l l I m a g e                                     %
00975 %                                                                             %
00976 %                                                                             %
00977 %                                                                             %
00978 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00979 %
00980 %  ColorFloodfill() changes the color value of any pixel that matches
00981 %  target and is an immediate neighbor.  If the method FillToBorderMethod is
00982 %  specified, the color value is changed for any neighbor pixel that does not
00983 %  match the bordercolor member of image.
00984 %
00985 %  By default target must match a particular pixel color exactly.
00986 %  However, in many cases two colors may differ by a small amount.  The
00987 %  fuzz member of image defines how much tolerance is acceptable to
00988 %  consider two colors as the same.  For example, set fuzz to 10 and the
00989 %  color red at intensities of 100 and 102 respectively are now
00990 %  interpreted as the same color for the purposes of the floodfill.
00991 %
00992 %  The format of the ColorFloodfillImage method is:
00993 %
00994 %      MagickBooleanType ColorFloodfillImage(Image *image,
00995 %        const DrawInfo *draw_info,const PixelPacket target,
00996 %        const long x_offset,const long y_offset,const PaintMethod method)
00997 %
00998 %  A description of each parameter follows:
00999 %
01000 %    o image: the image.
01001 %
01002 %    o draw_info: the draw info.
01003 %
01004 %    o target: the RGB value of the target color.
01005 %
01006 %    o x,y: the starting location of the operation.
01007 %
01008 %    o method: Choose either FloodfillMethod or FillToBorderMethod.
01009 %
01010 */
01011 
01012 #define MaxStacksize  (1UL << 15)
01013 #define PushSegmentStack(up,left,right,delta) \
01014 { \
01015   if (s >= (segment_stack+MaxStacksize)) \
01016     ThrowBinaryException(DrawError,"SegmentStackOverflow",image->filename) \
01017   else \
01018     { \
01019       if ((((up)+(delta)) >= 0) && (((up)+(delta)) < (long) image->rows)) \
01020         { \
01021           s->x1=(double) (left); \
01022           s->y1=(double) (up); \
01023           s->x2=(double) (right); \
01024           s->y2=(double) (delta); \
01025           s++; \
01026         } \
01027     } \
01028 }
01029 
01030 MagickExport MagickBooleanType ColorFloodfillImage(Image *image,
01031   const DrawInfo *draw_info,const PixelPacket target,const long x_offset,
01032   const long y_offset,const PaintMethod method)
01033 {
01034   Image
01035     *floodplane_image;
01036 
01037   long
01038     offset,
01039     start,
01040     x1,
01041     x2,
01042     y;
01043 
01044   MagickBooleanType
01045     skip;
01046 
01047   PixelPacket
01048     fill_color;
01049 
01050   register const PixelPacket
01051     *p;
01052 
01053   register long
01054     x;
01055 
01056   register PixelPacket
01057     *q;
01058 
01059   register SegmentInfo
01060     *s;
01061 
01062   SegmentInfo
01063     *segment_stack;
01064 
01065   /*
01066     Check boundary conditions.
01067   */
01068   assert(image != (Image *) NULL);
01069   assert(image->signature == MagickSignature);
01070   if (image->debug != MagickFalse)
01071     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
01072   assert(draw_info != (DrawInfo *) NULL);
01073   assert(draw_info->signature == MagickSignature);
01074   if ((x_offset < 0) || (x_offset >= (long) image->columns))
01075     return(MagickFalse);
01076   if ((y_offset < 0) || (y_offset >= (long) image->rows))
01077     return(MagickFalse);
01078   if (SetImageStorageClass(image,DirectClass) == MagickFalse)
01079     return(MagickFalse);
01080   if (image->matte == MagickFalse)
01081     (void) SetImageAlphaChannel(image,OpaqueAlphaChannel);
01082   floodplane_image=CloneImage(image,image->columns,image->rows,MagickTrue,
01083     &image->exception);
01084   if (floodplane_image == (Image *) NULL)
01085     return(MagickFalse);
01086   (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel);
01087   /*
01088     Set floodfill color.
01089   */
01090   segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize,
01091     sizeof(*segment_stack));
01092   if (segment_stack == (SegmentInfo *) NULL)
01093     {
01094       floodplane_image=DestroyImage(floodplane_image);
01095       ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
01096         image->filename);
01097     }
01098   /*
01099     Push initial segment on stack.
01100   */
01101   x=x_offset;
01102   y=y_offset;
01103   start=0;
01104   s=segment_stack;
01105   PushSegmentStack(y,x,x,1);
01106   PushSegmentStack(y+1,x,x,-1);
01107   while (s > segment_stack)
01108   {
01109     /*
01110       Pop segment off stack.
01111     */
01112     s--;
01113     x1=(long) s->x1;
01114     x2=(long) s->x2;
01115     offset=(long) s->y2;
01116     y=(long) s->y1+offset;
01117     /*
01118       Recolor neighboring pixels.
01119     */
01120     p=GetVirtualPixels(image,0,y,(unsigned long) (x1+1),1,&image->exception);
01121     q=GetAuthenticPixels(floodplane_image,0,y,(unsigned long) (x1+1),1,
01122       &image->exception);
01123     if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
01124       break;
01125     p+=x1;
01126     q+=x1;
01127     for (x=x1; x >= 0; x--)
01128     {
01129       if (q->opacity == (Quantum) TransparentOpacity)
01130         break;
01131       if (method == FloodfillMethod)
01132         {
01133           if (IsColorSimilar(image,p,&target) == MagickFalse)
01134             break;
01135         }
01136       else
01137         if (IsColorSimilar(image,p,&target) !=