magick-wand.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %                 M   M   AAA    GGGG  IIIII   CCCC  K   K                    %
00007 %                 MM MM  A   A  G        I    C      K  K                     %
00008 %                 M M M  AAAAA  G GGG    I    C      KKK                      %
00009 %                 M   M  A   A  G   G    I    C      K  K                     %
00010 %                 M   M  A   A   GGGG  IIIII   CCCC  K   K                    %
00011 %                                                                             %
00012 %                        W   W   AAA   N   N  DDDD                            %
00013 %                        W   W  A   A  NN  N  D   D                           %
00014 %                        W W W  AAAAA  N N N  D   D                           %
00015 %                        WW WW  A   A  N  NN  D   D                           %
00016 %                        W   W  A   A  N   N  DDDD                            %
00017 %                                                                             %
00018 %                                                                             %
00019 %                           MagickWand Wand Methods                           %
00020 %                                                                             %
00021 %                               Software Design                               %
00022 %                                 John Cristy                                 %
00023 %                                 August 2003                                 %
00024 %                                                                             %
00025 %                                                                             %
00026 %  Copyright 1999-2010 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 "wand/studio.h"
00050 #include "wand/MagickWand.h"
00051 #include "wand/magick-wand-private.h"
00052 #include "wand/wand.h"
00053 
00054 /*
00055   Define declarations.
00056 */
00057 #define ThrowWandException(severity,tag,context) \
00058 { \
00059   (void) ThrowMagickException(wand->exception,GetMagickModule(),severity, \
00060     tag,"`%s'",context); \
00061   return(MagickFalse); \
00062 }
00063 
00064 /*
00065 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00066 %                                                                             %
00067 %                                                                             %
00068 %                                                                             %
00069 %   C l e a r M a g i c k W a n d                                             %
00070 %                                                                             %
00071 %                                                                             %
00072 %                                                                             %
00073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00074 %
00075 %  ClearMagickWand() clears resources associated with the wand.
00076 %
00077 %  The format of the ClearMagickWand method is:
00078 %
00079 %      void ClearMagickWand(MagickWand *wand)
00080 %
00081 %  A description of each parameter follows:
00082 %
00083 %    o wand: the magick wand.
00084 %
00085 */
00086 WandExport void ClearMagickWand(MagickWand *wand)
00087 {
00088   assert(wand != (MagickWand *) NULL);
00089   assert(wand->signature == WandSignature);
00090   if (wand->debug != MagickFalse)
00091     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00092   wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info);
00093   wand->image_info=DestroyImageInfo(wand->image_info);
00094   wand->images=DestroyImageList(wand->images);
00095   wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL);
00096   wand->image_info=AcquireImageInfo();
00097   ClearMagickException(wand->exception);
00098   wand->debug=IsEventLogging();
00099 }
00100 
00101 /*
00102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00103 %                                                                             %
00104 %                                                                             %
00105 %                                                                             %
00106 %   C l o n e M a g i c k W a n d                                             %
00107 %                                                                             %
00108 %                                                                             %
00109 %                                                                             %
00110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00111 %
00112 %  CloneMagickWand() makes an exact copy of the specified wand.
00113 %
00114 %  The format of the CloneMagickWand method is:
00115 %
00116 %      MagickWand *CloneMagickWand(const MagickWand *wand)
00117 %
00118 %  A description of each parameter follows:
00119 %
00120 %    o wand: the magick wand.
00121 %
00122 */
00123 WandExport MagickWand *CloneMagickWand(const MagickWand *wand)
00124 {
00125   MagickWand
00126     *clone_wand;
00127 
00128   assert(wand != (MagickWand *) NULL);
00129   assert(wand->signature == WandSignature);
00130   if (wand->debug != MagickFalse)
00131     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00132   clone_wand=(MagickWand *) AcquireAlignedMemory(1,sizeof(*clone_wand));
00133   if (clone_wand == (MagickWand *) NULL)
00134     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
00135       wand->name);
00136   (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand));
00137   clone_wand->id=AcquireWandId();
00138   (void) FormatMagickString(clone_wand->name,MaxTextExtent,"%s-%lu",
00139     MagickWandId,clone_wand->id);
00140   clone_wand->exception=AcquireExceptionInfo();
00141   InheritException(clone_wand->exception,wand->exception);
00142   clone_wand->image_info=CloneImageInfo(wand->image_info);
00143   clone_wand->quantize_info=CloneQuantizeInfo(wand->quantize_info);
00144   clone_wand->images=CloneImageList(wand->images,clone_wand->exception);
00145   clone_wand->debug=IsEventLogging();
00146   if (clone_wand->debug != MagickFalse)
00147     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name);
00148   clone_wand->signature=WandSignature;
00149   return(clone_wand);
00150 }
00151 
00152 /*
00153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00154 %                                                                             %
00155 %                                                                             %
00156 %                                                                             %
00157 %   D e s t r o y M a g i c k W a n d                                         %
00158 %                                                                             %
00159 %                                                                             %
00160 %                                                                             %
00161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00162 %
00163 %  DestroyMagickWand() deallocates memory associated with an MagickWand.
00164 %
00165 %  The format of the DestroyMagickWand method is:
00166 %
00167 %      MagickWand *DestroyMagickWand(MagickWand *wand)
00168 %
00169 %  A description of each parameter follows:
00170 %
00171 %    o wand: the magick wand.
00172 %
00173 */
00174 WandExport MagickWand *DestroyMagickWand(MagickWand *wand)
00175 {
00176   assert(wand != (MagickWand *) NULL);
00177   assert(wand->signature == WandSignature);
00178   if (wand->debug != MagickFalse)
00179     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00180   wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info);
00181   wand->image_info=DestroyImageInfo(wand->image_info);
00182   wand->images=DestroyImageList(wand->images);
00183   wand->exception=DestroyExceptionInfo(wand->exception);
00184   RelinquishWandId(wand->id);
00185   wand->signature=(~WandSignature);
00186   wand=(MagickWand *) RelinquishMagickMemory(wand);
00187   return(wand);
00188 }
00189 
00190 /*
00191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00192 %                                                                             %
00193 %                                                                             %
00194 %                                                                             %
00195 %   I s M a g i c k W a n d                                                   %
00196 %                                                                             %
00197 %                                                                             %
00198 %                                                                             %
00199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00200 %
00201 %  IsMagickWand() returns MagickTrue if the wand is verified as a magick wand.
00202 %
00203 %  The format of the IsMagickWand method is:
00204 %
00205 %      MagickBooleanType IsMagickWand(const MagickWand *wand)
00206 %
00207 %  A description of each parameter follows:
00208 %
00209 %    o wand: the magick wand.
00210 %
00211 */
00212 WandExport MagickBooleanType IsMagickWand(const MagickWand *wand)
00213 {
00214   if (wand == (const MagickWand *) NULL)
00215     return(MagickFalse);
00216   if (wand->signature != WandSignature)
00217     return(MagickFalse);
00218   if (LocaleNCompare(wand->name,MagickWandId,strlen(MagickWandId)) != 0)
00219     return(MagickFalse);
00220   return(MagickTrue);
00221 }
00222 
00223 /*
00224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00225 %                                                                             %
00226 %                                                                             %
00227 %                                                                             %
00228 %   M a g i c k C l e a r E x c e p t i o n                                   %
00229 %                                                                             %
00230 %                                                                             %
00231 %                                                                             %
00232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00233 %
00234 %  MagickClearException() clears any exceptions associated with the wand.
00235 %
00236 %  The format of the MagickClearException method is:
00237 %
00238 %      MagickBooleanType MagickClearException(MagickWand *wand)
00239 %
00240 %  A description of each parameter follows:
00241 %
00242 %    o wand: the magick wand.
00243 %
00244 */
00245 WandExport MagickBooleanType MagickClearException(MagickWand *wand)
00246 {
00247   assert(wand != (MagickWand *) NULL);
00248   assert(wand->signature == WandSignature);
00249   if (wand->debug != MagickFalse)
00250     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00251   ClearMagickException(wand->exception);
00252   return(MagickTrue);
00253 }
00254 
00255 /*
00256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00257 %                                                                             %
00258 %                                                                             %
00259 %                                                                             %
00260 %   M a g i c k G e t E x c e p t i o n                                       %
00261 %                                                                             %
00262 %                                                                             %
00263 %                                                                             %
00264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00265 %
00266 %  MagickGetException() returns the severity, reason, and description of any
00267 %  error that occurs when using other methods in this API.
00268 %
00269 %  The format of the MagickGetException method is:
00270 %
00271 %      char *MagickGetException(const MagickWand *wand,ExceptionType *severity)
00272 %
00273 %  A description of each parameter follows:
00274 %
00275 %    o wand: the magick wand.
00276 %
00277 %    o severity: the severity of the error is returned here.
00278 %
00279 */
00280 WandExport char *MagickGetException(const MagickWand *wand,
00281   ExceptionType *severity)
00282 {
00283   char
00284     *description;
00285 
00286   assert(wand != (const MagickWand *) NULL);
00287   assert(wand->signature == WandSignature);
00288   if (wand->debug != MagickFalse)
00289     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00290   assert(severity != (ExceptionType *) NULL);
00291   *severity=wand->exception->severity;
00292   description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent,
00293     sizeof(*description));
00294   if (description == (char *) NULL)
00295     {
00296       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
00297         "MemoryAllocationFailed","`%s'",wand->name);
00298       return((char *) NULL);
00299     }
00300   *description='\0';
00301   if (wand->exception->reason != (char *) NULL)
00302     (void) CopyMagickString(description,GetLocaleExceptionMessage(
00303       wand->exception->severity,wand->exception->reason),MaxTextExtent);
00304   if (wand->exception->description != (char *) NULL)
00305     {
00306       (void) ConcatenateMagickString(description," (",MaxTextExtent);
00307       (void) ConcatenateMagickString(description,GetLocaleExceptionMessage(
00308         wand->exception->severity,wand->exception->description),MaxTextExtent);
00309       (void) ConcatenateMagickString(description,")",MaxTextExtent);
00310     }
00311   return(description);
00312 }
00313 
00314 /*
00315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00316 %                                                                             %
00317 %                                                                             %
00318 %                                                                             %
00319 %   M a g i c k G e t  E x c e p t i o n T y p e                              %
00320 %                                                                             %
00321 %                                                                             %
00322 %                                                                             %
00323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00324 %
00325 %  MagickGetExceptionType() returns the exception type associated with the
00326 %  wand.  If no exception has occurred, UndefinedExceptionType is returned.
00327 %
00328 %  The format of the MagickGetExceptionType method is:
00329 %
00330 %      ExceptionType MagickGetExceptionType(const MagickWand *wand)
00331 %
00332 %  A description of each parameter follows:
00333 %
00334 %    o wand: the magick wand.
00335 %
00336 */
00337 WandExport ExceptionType MagickGetExceptionType(const MagickWand *wand)
00338 {
00339   assert(wand != (MagickWand *) NULL);
00340   assert(wand->signature == WandSignature);
00341   if (wand->debug != MagickFalse)
00342     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00343   return(wand->exception->severity);
00344 }
00345 
00346 /*
00347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00348 %                                                                             %
00349 %                                                                             %
00350 %                                                                             %
00351 %   M a g i c k G e t I t e r a t o r I n d e x                               %
00352 %                                                                             %
00353 %                                                                             %
00354 %                                                                             %
00355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00356 %
00357 %  MagickGetIteratorIndex() returns the position of the iterator in the image
00358 %  list.
00359 %
00360 %  The format of the MagickGetIteratorIndex method is:
00361 %
00362 %      long MagickGetIteratorIndex(MagickWand *wand)
00363 %
00364 %  A description of each parameter follows:
00365 %
00366 %    o wand: the magick wand.
00367 %
00368 */
00369 WandExport long MagickGetIteratorIndex(MagickWand *wand)
00370 {
00371   assert(wand != (MagickWand *) NULL);
00372   assert(wand->signature == WandSignature);
00373   if (wand->debug != MagickFalse)
00374     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00375   if (wand->images == (Image *) NULL)
00376     {
00377       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
00378         "ContainsNoIterators","`%s'",wand->name);
00379       return(-1);
00380     }
00381   return(GetImageIndexInList(wand->images));
00382 }
00383 
00384 /*
00385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00386 %                                                                             %
00387 %                                                                             %
00388 %                                                                             %
00389 %   M a g i c k Q u e r y C o n f i g u r e O p t i o n                       %
00390 %                                                                             %
00391 %                                                                             %
00392 %                                                                             %
00393 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00394 %
00395 %  MagickQueryConfigureOption() returns the value associated with the specified
00396 %  configure option.
00397 %
00398 %  The format of the MagickQueryConfigureOption function is:
00399 %
00400 %      char *MagickQueryConfigureOption(const char *option)
00401 %
00402 %  A description of each parameter follows:
00403 %
00404 %    o option: the option name.
00405 %
00406 */
00407 WandExport char *MagickQueryConfigureOption(const char *option)
00408 {
00409   char
00410     *value;
00411 
00412   const ConfigureInfo
00413     **configure_info;
00414 
00415   ExceptionInfo
00416     *exception;
00417 
00418   unsigned long
00419     number_options;
00420 
00421   exception=AcquireExceptionInfo();
00422   configure_info=GetConfigureInfoList(option,&number_options,exception);
00423   exception=DestroyExceptionInfo(exception);
00424   if (configure_info == (const ConfigureInfo **) NULL)
00425     return((char *) NULL);
00426   value=AcquireString(configure_info[0]->value);
00427   configure_info=(const ConfigureInfo **)
00428     RelinquishMagickMemory((void *) configure_info);
00429   return(value);
00430 }
00431 
00432 /*
00433 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00434 %                                                                             %
00435 %                                                                             %
00436 %                                                                             %
00437 %   M a g i c k Q u e r y C o n f i g u r e O p t i o n s                     %
00438 %                                                                             %
00439 %                                                                             %
00440 %                                                                             %
00441 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00442 %
00443 %  MagickQueryConfigureOptions() returns any configure options that match the
00444 %  specified pattern (e.g.  "*" for all).  Options include NAME, VERSION,
00445 %  LIB_VERSION, etc.
00446 %
00447 %  The format of the MagickQueryConfigureOptions function is:
00448 %
00449 %      char **MagickQueryConfigureOptions(const char *pattern,
00450 %        unsigned long *number_options)
00451 %
00452 %  A description of each parameter follows:
00453 %
00454 %    o pattern: Specifies a pointer to a text string containing a pattern.
00455 %
00456 %    o number_options:  Returns the number of configure options in the list.
00457 %
00458 %
00459 */
00460 WandExport char **MagickQueryConfigureOptions(const char *pattern,
00461   unsigned long *number_options)
00462 {
00463   char
00464     **options;
00465 
00466   ExceptionInfo
00467     *exception;
00468 
00469   exception=AcquireExceptionInfo();
00470   options=GetConfigureList(pattern,number_options,exception);
00471   exception=DestroyExceptionInfo(exception);
00472   return(options);
00473 }
00474 
00475 /*
00476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00477 %                                                                             %
00478 %                                                                             %
00479 %                                                                             %
00480 %   M a g i c k Q u e r y F o n t M e t r i c s                               %
00481 %                                                                             %
00482 %                                                                             %
00483 %                                                                             %
00484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00485 %
00486 %  MagickQueryFontMetrics() returns a 13 element array representing the
00487 %  following font metrics:
00488 %
00489 %    Element Description
00490 %    -------------------------------------------------
00491 %          0 character width
00492 %          1 character height
00493 %          2 ascender
00494 %          3 descender
00495 %          4 text width
00496 %          5 text height
00497 %          6 maximum horizontal advance
00498 %          7 bounding box: x1
00499 %          8 bounding box: y1
00500 %          9 bounding box: x2
00501 %         10 bounding box: y2
00502 %         11 origin: x
00503 %         12 origin: y
00504 %
00505 %  The format of the MagickQueryFontMetrics method is:
00506 %
00507 %      double *MagickQueryFontMetrics(MagickWand *wand,
00508 %        const DrawingWand *drawing_wand,const char *text)
00509 %
00510 %  A description of each parameter follows:
00511 %
00512 %    o wand: the Magick wand.
00513 %
00514 %    o drawing_wand: the drawing wand.
00515 %
00516 %    o text: the text.
00517 %
00518 */
00519 WandExport double *MagickQueryFontMetrics(MagickWand *wand,
00520   const DrawingWand *drawing_wand,const char *text)
00521 {
00522   double
00523     *font_metrics;
00524 
00525   DrawInfo
00526     *draw_info;
00527 
00528   MagickBooleanType
00529     status;
00530 
00531   TypeMetric
00532     metrics;
00533 
00534   assert(wand != (MagickWand *) NULL);
00535   assert(wand->signature == WandSignature);
00536   if (wand->debug != MagickFalse)
00537     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00538   assert(drawing_wand != (const DrawingWand *) NULL);
00539   if (wand->images == (Image *) NULL)
00540     {
00541       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
00542         "ContainsNoImages","`%s'",wand->name);
00543       return((double *) NULL);
00544     }
00545   font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics));
00546   if (font_metrics == (double *) NULL)
00547     return((double *) NULL);
00548   draw_info=PeekDrawingWand(drawing_wand);
00549   if (draw_info == (DrawInfo *) NULL)
00550     {
00551       font_metrics=(double *) RelinquishMagickMemory(font_metrics);
00552       return((double *) NULL);
00553     }
00554   (void) CloneString(&draw_info->text,text);
00555   (void) ResetMagickMemory(&metrics,0,sizeof(metrics));
00556   status=GetTypeMetrics(wand->images,draw_info,&metrics);
00557   draw_info=DestroyDrawInfo(draw_info);
00558   if (status == MagickFalse)
00559     {
00560       InheritException(wand->exception,&wand->images->exception);
00561       font_metrics=(double *) RelinquishMagickMemory(font_metrics);
00562       return((double *) NULL);
00563     }
00564   font_metrics[0]=metrics.pixels_per_em.x;
00565   font_metrics[1]=metrics.pixels_per_em.y;
00566   font_metrics[2]=metrics.ascent;
00567   font_metrics[3]=metrics.descent;
00568   font_metrics[4]=metrics.width;
00569   font_metrics[5]=metrics.height;
00570   font_metrics[6]=metrics.max_advance;
00571   font_metrics[7]=metrics.bounds.x1;
00572   font_metrics[8]=metrics.bounds.y1;
00573   font_metrics[9]=metrics.bounds.x2;
00574   font_metrics[10]=metrics.bounds.y2;
00575   font_metrics[11]=metrics.origin.x;
00576   font_metrics[12]=metrics.origin.y;
00577   return(font_metrics);
00578 }
00579 
00580 /*
00581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00582 %                                                                             %
00583 %                                                                             %
00584 %                                                                             %
00585 %   M a g i c k Q u e r y M u l t i l i n e F o n t M e t r i c s             %
00586 %                                                                             %
00587 %                                                                             %
00588 %                                                                             %
00589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00590 %
00591 %  MagickQueryMultilineFontMetrics() returns a 13 element array representing the
00592 %  following font metrics:
00593 %
00594 %    Element Description
00595 %    -------------------------------------------------
00596 %          0 character width
00597 %          1 character height
00598 %          2 ascender
00599 %          3 descender
00600 %          4 text width
00601 %          5 text height
00602 %          6 maximum horizontal advance
00603 %          7 bounding box: x1
00604 %          8 bounding box: y1
00605 %          9 bounding box: x2
00606 %         10 bounding box: y2
00607 %         11 origin: x
00608 %         12 origin: y
00609 %
00610 %  This method is like MagickQueryFontMetrics() but it returns the maximum text
00611 %  width and height for multiple lines of text.
00612 %
00613 %  The format of the MagickQueryFontMetrics method is:
00614 %
00615 %      double *MagickQueryMultilineFontMetrics(MagickWand *wand,
00616 %        const DrawingWand *drawing_wand,const char *text)
00617 %
00618 %  A description of each parameter follows:
00619 %
00620 %    o wand: the Magick wand.
00621 %
00622 %    o drawing_wand: the drawing wand.
00623 %
00624 %    o text: the text.
00625 %
00626 */
00627 WandExport double *MagickQueryMultilineFontMetrics(MagickWand *wand,
00628   const DrawingWand *drawing_wand,const char *text)
00629 {
00630   double
00631     *font_metrics;
00632 
00633   DrawInfo
00634     *draw_info;
00635 
00636   MagickBooleanType
00637     status;
00638 
00639   TypeMetric
00640     metrics;
00641 
00642   assert(wand != (MagickWand *) NULL);
00643   assert(wand->signature == WandSignature);
00644   if (wand->debug != MagickFalse)
00645     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00646   assert(drawing_wand != (const DrawingWand *) NULL);
00647   if (wand->images == (Image *) NULL)
00648     {
00649       (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError,
00650         "ContainsNoImages","`%s'",wand->name);
00651       return((double *) NULL);
00652     }
00653   font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics));
00654   if (font_metrics == (double *) NULL)
00655     return((double *) NULL);
00656   draw_info=PeekDrawingWand(drawing_wand);
00657   if (draw_info == (DrawInfo *) NULL)
00658     {
00659       font_metrics=(double *) RelinquishMagickMemory(font_metrics);
00660       return((double *) NULL);
00661     }
00662   (void) CloneString(&draw_info->text,text);
00663   (void) ResetMagickMemory(&metrics,0,sizeof(metrics));
00664   status=GetMultilineTypeMetrics(wand->images,draw_info,&metrics);
00665   draw_info=DestroyDrawInfo(draw_info);
00666   if (status == MagickFalse)
00667     {
00668       InheritException(wand->exception,&wand->images->exception);
00669       font_metrics=(double *) RelinquishMagickMemory(font_metrics);
00670       return((double *) NULL);
00671     }
00672   font_metrics[0]=metrics.pixels_per_em.x;
00673   font_metrics[1]=metrics.pixels_per_em.y;
00674   font_metrics[2]=metrics.ascent;
00675   font_metrics[3]=metrics.descent;
00676   font_metrics[4]=metrics.width;
00677   font_metrics[5]=metrics.height;
00678   font_metrics[6]=metrics.max_advance;
00679   font_metrics[7]=metrics.bounds.x1;
00680   font_metrics[8]=metrics.bounds.y1;
00681   font_metrics[9]=metrics.bounds.x2;
00682   font_metrics[10]=metrics.bounds.y2;
00683   font_metrics[11]=metrics.origin.x;
00684   font_metrics[12]=metrics.origin.y;
00685   return(font_metrics);
00686 }
00687 
00688 /*
00689 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00690 %                                                                             %
00691 %                                                                             %
00692 %                                                                             %
00693 %   M a g i c k Q u e r y F o n t s                                           %
00694 %                                                                             %
00695 %                                                                             %
00696 %                                                                             %
00697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00698 %
00699 %  MagickQueryFonts() returns any font that match the specified pattern (e.g.
00700 %  "*" for all).
00701 %
00702 %  The format of the MagickQueryFonts function is:
00703 %
00704 %      char **MagickQueryFonts(const char *pattern,unsigned long *number_fonts)
00705 %
00706 %  A description of each parameter follows:
00707 %
00708 %    o pattern: Specifies a pointer to a text string containing a pattern.
00709 %
00710 %    o number_fonts:  Returns the number of fonts in the list.
00711 %
00712 %
00713 */
00714 WandExport char **MagickQueryFonts(const char *pattern,
00715   unsigned long *number_fonts)
00716 {
00717   char
00718     **fonts;
00719 
00720   ExceptionInfo
00721     *exception;
00722 
00723   exception=AcquireExceptionInfo();
00724   fonts=GetTypeList(pattern,number_fonts,exception);
00725   exception=DestroyExceptionInfo(exception);
00726   return(fonts);
00727 }
00728 
00729 /*
00730 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00731 %                                                                             %
00732 %                                                                             %
00733 %                                                                             %
00734 %   M a g i c k Q u e r y F o r m a t s                                       %
00735 %                                                                             %
00736 %                                                                             %
00737 %                                                                             %
00738 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00739 %
00740 %  MagickQueryFonts() returns any image formats that match the specified
00741 %  pattern (e.g.  "*" for all).
00742 %
00743 %  The format of the MagickQueryFonts function is:
00744 %
00745 %      char **MagickQueryFonts(const char *pattern,
00746 %        unsigned long *number_formats)
00747 %
00748 %  A description of each parameter follows:
00749 %
00750 %    o pattern: Specifies a pointer to a text string containing a pattern.
00751 %
00752 %    o number_formats:  This integer returns the number of image formats in the
00753 %      list.
00754 %
00755 */
00756 WandExport char **MagickQueryFormats(const char *pattern,
00757   unsigned long *number_formats)
00758 {
00759   char
00760     **formats;
00761 
00762   ExceptionInfo
00763     *exception;
00764 
00765   exception=AcquireExceptionInfo();
00766   formats=GetMagickList(pattern,number_formats,exception);
00767   exception=DestroyExceptionInfo(exception);
00768   return(formats);
00769 }
00770 
00771 /*
00772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00773 %                                                                             %
00774 %                                                                             %
00775 %                                                                             %
00776 %   M a g i c k R e l i n q u i s h M e m o r y                               %
00777 %                                                                             %
00778 %                                                                             %
00779 %                                                                             %
00780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00781 %
00782 %  MagickRelinquishMemory() relinquishes memory resources returned by such
00783 %  methods as MagickIdentifyImage(), MagickGetException(), etc.
00784 %
00785 %  The format of the MagickRelinquishMemory method is:
00786 %
00787 %      void *MagickRelinquishMemory(void *resource)
00788 %
00789 %  A description of each parameter follows:
00790 %
00791 %    o resource: Relinquish the memory associated with this resource.
00792 %
00793 */
00794 WandExport void *MagickRelinquishMemory(void *memory)
00795 {
00796   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00797   return(RelinquishMagickMemory(memory));
00798 }
00799 
00800 /*
00801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00802 %                                                                             %
00803 %                                                                             %
00804 %                                                                             %
00805 %   M a g i c k R e s e t I t e r a t o r                                     %
00806 %                                                                             %
00807 %                                                                             %
00808 %                                                                             %
00809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00810 %
00811 %  MagickResetIterator() resets the wand iterator.  Use it in conjunction
00812 %  with MagickNextImage() to iterate over all the images in a wand
00813 %  container.
00814 %
00815 %  The format of the MagickResetIterator method is:
00816 %
00817 %      void MagickResetIterator(MagickWand *wand)
00818 %
00819 %  A description of each parameter follows:
00820 %
00821 %    o wand: the magick wand.
00822 %
00823 */
00824 WandExport void MagickResetIterator(MagickWand *wand)
00825 {
00826   assert(wand != (MagickWand *) NULL);
00827   assert(wand->signature == WandSignature);
00828   if (wand->debug != MagickFalse)
00829     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00830   wand->active=MagickFalse;
00831   wand->pend=MagickTrue;
00832   wand->images=GetFirstImageInList(wand->images);
00833 }
00834 
00835 /*
00836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00837 %                                                                             %
00838 %                                                                             %
00839 %                                                                             %
00840 %   M a g i c k S e t F i r s t I t e r a t o r                               %
00841 %                                                                             %
00842 %                                                                             %
00843 %                                                                             %
00844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00845 %
00846 %  MagickSetFirstIterator() sets the wand iterator to the first image.
00847 %
00848 %  The format of the MagickSetFirstIterator method is:
00849 %
00850 %      void MagickSetFirstIterator(MagickWand *wand)
00851 %
00852 %  A description of each parameter follows:
00853 %
00854 %    o wand: the magick wand.
00855 %
00856 */
00857 WandExport void MagickSetFirstIterator(MagickWand *wand)
00858 {
00859   assert(wand != (MagickWand *) NULL);
00860   assert(wand->signature == WandSignature);
00861   if (wand->debug != MagickFalse)
00862     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00863   wand->active=MagickTrue;
00864   wand->pend=MagickFalse;
00865   wand->images=GetFirstImageInList(wand->images);
00866 }
00867 
00868 /*
00869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00870 %                                                                             %
00871 %                                                                             %
00872 %                                                                             %
00873 %   M a g i c k S e t I t e r a t o r I n d e x                               %
00874 %                                                                             %
00875 %                                                                             %
00876 %                                                                             %
00877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00878 %
00879 %  MagickSetIteratorIndex() set the iterator to the position in the image list
00880 %  specified with the index parameter.
00881 %
00882 %  The format of the MagickSetIteratorIndex method is:
00883 %
00884 %      MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
00885 %        const long index)
00886 %
00887 %  A description of each parameter follows:
00888 %
00889 %    o wand: the magick wand.
00890 %
00891 %    o index: the scene number.
00892 %
00893 */
00894 WandExport MagickBooleanType MagickSetIteratorIndex(MagickWand *wand,
00895   const long index)
00896 {
00897   Image
00898     *image;
00899 
00900   assert(wand != (MagickWand *) NULL);
00901   assert(wand->signature == WandSignature);
00902   if (wand->debug != MagickFalse)
00903     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00904   if (wand->images == (Image *) NULL)
00905     return(MagickFalse);
00906   image=GetImageFromList(wand->images,index);
00907   if (image == (Image *) NULL)
00908     {
00909       InheritException(wand->exception,&wand->images->exception);
00910       return(MagickFalse);
00911     }
00912   wand->active=MagickTrue;
00913   wand->pend=MagickFalse;
00914   wand->images=image;
00915   return(MagickTrue);
00916 }
00917 /*
00918 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00919 %                                                                             %
00920 %                                                                             %
00921 %                                                                             %
00922 %   M a g i c k S e t L a s t I t e r a t o r                                 %
00923 %                                                                             %
00924 %                                                                             %
00925 %                                                                             %
00926 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00927 %
00928 %  MagickSetLastIterator() sets the wand iterator to the last image.
00929 %
00930 %  The format of the MagickSetLastIterator method is:
00931 %
00932 %      void MagickSetLastIterator(MagickWand *wand)
00933 %
00934 %  A description of each parameter follows:
00935 %
00936 %    o wand: the magick wand.
00937 %
00938 */
00939 WandExport void MagickSetLastIterator(MagickWand *wand)
00940 {
00941   assert(wand != (MagickWand *) NULL);
00942   assert(wand->signature == WandSignature);
00943   if (wand->debug != MagickFalse)
00944     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
00945   wand->active=MagickFalse;
00946   wand->pend=MagickTrue;
00947   wand->images=GetLastImageInList(wand->images);
00948 }
00949 
00950 /*
00951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00952 %                                                                             %
00953 %                                                                             %
00954 %                                                                             %
00955 %   M a g i c k W a n d G e n e s i s                                         %
00956 %                                                                             %
00957 %                                                                             %
00958 %                                                                             %
00959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00960 %
00961 %  MagickWandGenesis() initializes the MagickWand environment.
00962 %
00963 %  The format of the MagickWandGenesis method is:
00964 %
00965 %      void MagickWandGenesis(void)
00966 %
00967 */
00968 WandExport void MagickWandGenesis(void)
00969 {
00970   if (IsMagickInstantiated() == MagickFalse)
00971     MagickCoreGenesis((char *) NULL,MagickFalse);
00972 }
00973 
00974 /*
00975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00976 %                                                                             %
00977 %                                                                             %
00978 %                                                                             %
00979 %   M a g i c k W a n d T e r m i n u s                                       %
00980 %                                                                             %
00981 %                                                                             %
00982 %                                                                             %
00983 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00984 %
00985 %  MagickWandTerminus() terminates the MagickWand environment.
00986 %
00987 %  The format of the MaickWandTerminus method is:
00988 %
00989 %      void MagickWandTerminus(void)
00990 %
00991 */
00992 WandExport void MagickWandTerminus(void)
00993 {
00994   DestroyWandIds();
00995   MagickCoreTerminus();
00996 }
00997 
00998 /*
00999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01000 %                                                                             %
01001 %                                                                             %
01002 %                                                                             %
01003 %   N e w M a g i c k W a n d                                                 %
01004 %                                                                             %
01005 %                                                                             %
01006 %                                                                             %
01007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01008 %
01009 %  NewMagickWand() returns a wand required for all other methods in the API.
01010 %
01011 %  The format of the NewMagickWand method is:
01012 %
01013 %      MagickWand *NewMagickWand(void)
01014 %
01015 */
01016 WandExport MagickWand *NewMagickWand(void)
01017 {
01018   const char
01019     *quantum;
01020 
01021   MagickWand
01022     *wand;
01023 
01024   unsigned long
01025     depth;
01026 
01027   depth=MAGICKCORE_QUANTUM_DEPTH;
01028   quantum=GetMagickQuantumDepth(&depth);
01029   if (depth != MAGICKCORE_QUANTUM_DEPTH)
01030     ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum);
01031   wand=(MagickWand *) AcquireAlignedMemory(1,sizeof(*wand));
01032   if (wand == (MagickWand *) NULL)
01033     ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
01034       GetExceptionMessage(errno));
01035   (void) ResetMagickMemory(wand,0,sizeof(*wand));
01036   wand->id=AcquireWandId();
01037   (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%lu",MagickWandId,
01038     wand->id);
01039   wand->exception=AcquireExceptionInfo();
01040   wand->image_info=AcquireImageInfo();
01041   wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL);
01042   wand->images=NewImageList();
01043   wand->debug=IsEventLogging();
01044   if (wand->debug != MagickFalse)
01045     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
01046   wand->signature=WandSignature;
01047   return(wand);
01048 }
01049 
01050 /*
01051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01052 %                                                                             %
01053 %                                                                             %
01054 %                                                                             %
01055 %   N e w M a g i c k W a n d F r o m I m a g e                               %
01056 %                                                                             %
01057 %                                                                             %
01058 %                                                                             %
01059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01060 %
01061 %  NewMagickWandFromImage() returns a wand with an image.
01062 %
01063 %  The format of the NewMagickWandFromImage method is:
01064 %
01065 %      MagickWand *NewMagickWandFromImage(const Image *image)
01066 %
01067 %  A description of each parameter follows:
01068 %
01069 %    o image: the image.
01070 %
01071 */
01072 WandExport MagickWand *NewMagickWandFromImage(const Image *image)
01073 {
01074   MagickWand
01075     *wand;
01076 
01077   wand=NewMagickWand();
01078   wand->images=CloneImage(image,0,0,MagickTrue,wand->exception);
01079   return(wand);
01080 }
Generated by  doxygen 1.6.2-20100208