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