cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M AAA GGGG IIIII CCCC K K % |
| 7 | % MM MM A A G I C K K % |
| 8 | % M M M AAAAA G GGG I C KKK % |
| 9 | % M M A A G G I C K K % |
| 10 | % M M A A GGGG IIIII CCCC K K % |
| 11 | % % |
| 12 | % W W AAA N N DDDD % |
| 13 | % W W A A NN N D D % |
| 14 | % W W W AAAAA N N N D D % |
| 15 | % WW WW A A N NN D D % |
| 16 | % W W A A N N DDDD % |
| 17 | % % |
| 18 | % % |
| 19 | % MagickWand Wand Methods % |
| 20 | % % |
| 21 | % Software Design % |
| 22 | % John Cristy % |
| 23 | % August 2003 % |
| 24 | % % |
| 25 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 26 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 27 | % dedicated to making software imaging solutions freely available. % |
| 28 | % % |
| 29 | % You may not use this file except in compliance with the License. You may % |
| 30 | % obtain a copy of the License at % |
| 31 | % % |
| 32 | % http://www.imagemagick.org/script/license.php % |
| 33 | % % |
| 34 | % Unless required by applicable law or agreed to in writing, software % |
| 35 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 36 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 37 | % See the License for the specific language governing permissions and % |
| 38 | % limitations under the License. % |
| 39 | % % |
| 40 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 | % |
| 42 | % |
| 43 | % |
| 44 | */ |
| 45 | |
| 46 | /* |
| 47 | Include declarations. |
| 48 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 49 | #include "MagickWand/studio.h" |
| 50 | #include "MagickWand/MagickWand.h" |
| 51 | #include "MagickWand/magick-wand-private.h" |
| 52 | #include "MagickWand/wand.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | Define declarations. |
| 56 | */ |
| 57 | #define ThrowWandException(severity,tag,context) \ |
| 58 | { \ |
| 59 | (void) ThrowMagickException(wand->exception,GetMagickModule(),severity, \ |
| 60 | tag,"`%s'",context); \ |
| 61 | return(MagickFalse); \ |
| 62 | } |
| 63 | |
| 64 | /* |
| 65 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 66 | % % |
| 67 | % % |
| 68 | % % |
| 69 | % C l e a r M a g i c k W a n d % |
| 70 | % % |
| 71 | % % |
| 72 | % % |
| 73 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 74 | % |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 75 | % ClearMagickWand() clears resources associated with the wand, leaving the |
| 76 | % wand blank, and ready to be used for a new set of images. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 77 | % |
| 78 | % The format of the ClearMagickWand method is: |
| 79 | % |
| 80 | % void ClearMagickWand(MagickWand *wand) |
| 81 | % |
| 82 | % A description of each parameter follows: |
| 83 | % |
| 84 | % o wand: the magick wand. |
| 85 | % |
| 86 | */ |
| 87 | WandExport void ClearMagickWand(MagickWand *wand) |
| 88 | { |
| 89 | assert(wand != (MagickWand *) NULL); |
| 90 | assert(wand->signature == WandSignature); |
| 91 | if (wand->debug != MagickFalse) |
| 92 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 93 | wand->images=DestroyImageList(wand->images); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 94 | if (wand->quantize_info != (QuantizeInfo *) NULL ) |
| 95 | wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info); |
| 96 | if (wand->draw_info != (DrawInfo *) NULL ) |
| 97 | wand->draw_info=DestroyDrawInfo(wand->draw_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 98 | wand->image_info=AcquireImageInfo(); |
| 99 | ClearMagickException(wand->exception); |
| 100 | wand->debug=IsEventLogging(); |
| 101 | } |
| 102 | |
| 103 | /* |
| 104 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 105 | % % |
| 106 | % % |
| 107 | % % |
| 108 | % C l o n e M a g i c k W a n d % |
| 109 | % % |
| 110 | % % |
| 111 | % % |
| 112 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 113 | % |
| 114 | % CloneMagickWand() makes an exact copy of the specified wand. |
| 115 | % |
| 116 | % The format of the CloneMagickWand method is: |
| 117 | % |
| 118 | % MagickWand *CloneMagickWand(const MagickWand *wand) |
| 119 | % |
| 120 | % A description of each parameter follows: |
| 121 | % |
| 122 | % o wand: the magick wand. |
| 123 | % |
| 124 | */ |
| 125 | WandExport MagickWand *CloneMagickWand(const MagickWand *wand) |
| 126 | { |
| 127 | MagickWand |
| 128 | *clone_wand; |
| 129 | |
| 130 | assert(wand != (MagickWand *) NULL); |
| 131 | assert(wand->signature == WandSignature); |
| 132 | if (wand->debug != MagickFalse) |
| 133 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 134 | clone_wand=(MagickWand *) AcquireMagickMemory(sizeof(*clone_wand)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 135 | if (clone_wand == (MagickWand *) NULL) |
| 136 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 137 | wand->name); |
| 138 | (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand)); |
| 139 | clone_wand->id=AcquireWandId(); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 140 | (void) FormatLocaleString(clone_wand->name,MaxTextExtent,"%s-%.20g", |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 141 | MagickWandId,(double) clone_wand->id); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 142 | clone_wand->exception=AcquireExceptionInfo(); |
| 143 | InheritException(clone_wand->exception,wand->exception); |
| 144 | clone_wand->image_info=CloneImageInfo(wand->image_info); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 145 | if ( wand->quantize_info == (QuantizeInfo *) NULL ) |
| 146 | clone_wand->quantize_info=(QuantizeInfo *) NULL; |
| 147 | else |
| 148 | clone_wand->quantize_info=CloneQuantizeInfo(wand->quantize_info); |
| 149 | if ( wand->draw_info == (DrawInfo *) NULL ) |
| 150 | clone_wand->draw_info=(DrawInfo *) NULL; |
| 151 | else |
anthony | 63f3bca | 2011-10-04 23:49:57 +0000 | [diff] [blame] | 152 | clone_wand->draw_info=CloneDrawInfo(wand->image_info,wand->draw_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | clone_wand->images=CloneImageList(wand->images,clone_wand->exception); |
| 154 | clone_wand->debug=IsEventLogging(); |
| 155 | if (clone_wand->debug != MagickFalse) |
| 156 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name); |
| 157 | clone_wand->signature=WandSignature; |
| 158 | return(clone_wand); |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 163 | % % |
| 164 | % % |
| 165 | % % |
| 166 | % D e s t r o y M a g i c k W a n d % |
| 167 | % % |
| 168 | % % |
| 169 | % % |
| 170 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 171 | % |
| 172 | % DestroyMagickWand() deallocates memory associated with an MagickWand. |
| 173 | % |
| 174 | % The format of the DestroyMagickWand method is: |
| 175 | % |
| 176 | % MagickWand *DestroyMagickWand(MagickWand *wand) |
| 177 | % |
| 178 | % A description of each parameter follows: |
| 179 | % |
| 180 | % o wand: the magick wand. |
| 181 | % |
| 182 | */ |
| 183 | WandExport MagickWand *DestroyMagickWand(MagickWand *wand) |
| 184 | { |
| 185 | assert(wand != (MagickWand *) NULL); |
| 186 | assert(wand->signature == WandSignature); |
| 187 | if (wand->debug != MagickFalse) |
| 188 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
anthony | d2706c7 | 2012-02-10 12:51:17 +0000 | [diff] [blame^] | 189 | wand->images=DestroyImageList(wand->images); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 190 | if (wand->quantize_info != (QuantizeInfo *) NULL ) |
| 191 | wand->quantize_info=DestroyQuantizeInfo(wand->quantize_info); |
| 192 | if (wand->draw_info != (DrawInfo *) NULL ) |
| 193 | wand->draw_info=DestroyDrawInfo(wand->draw_info); |
anthony | d2706c7 | 2012-02-10 12:51:17 +0000 | [diff] [blame^] | 194 | if (wand->image_info != (ImageInfo *) NULL ) |
| 195 | wand->image_info=DestroyImageInfo(wand->image_info); |
| 196 | if (wand->exception != (ExceptionInfo *) NULL ) |
| 197 | wand->exception=DestroyExceptionInfo(wand->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 198 | RelinquishWandId(wand->id); |
| 199 | wand->signature=(~WandSignature); |
| 200 | wand=(MagickWand *) RelinquishMagickMemory(wand); |
| 201 | return(wand); |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 206 | % % |
| 207 | % % |
| 208 | % % |
| 209 | % I s M a g i c k W a n d % |
| 210 | % % |
| 211 | % % |
| 212 | % % |
| 213 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 214 | % |
| 215 | % IsMagickWand() returns MagickTrue if the wand is verified as a magick wand. |
| 216 | % |
| 217 | % The format of the IsMagickWand method is: |
| 218 | % |
| 219 | % MagickBooleanType IsMagickWand(const MagickWand *wand) |
| 220 | % |
| 221 | % A description of each parameter follows: |
| 222 | % |
| 223 | % o wand: the magick wand. |
| 224 | % |
| 225 | */ |
| 226 | WandExport MagickBooleanType IsMagickWand(const MagickWand *wand) |
| 227 | { |
| 228 | if (wand == (const MagickWand *) NULL) |
| 229 | return(MagickFalse); |
| 230 | if (wand->signature != WandSignature) |
| 231 | return(MagickFalse); |
| 232 | if (LocaleNCompare(wand->name,MagickWandId,strlen(MagickWandId)) != 0) |
| 233 | return(MagickFalse); |
| 234 | return(MagickTrue); |
| 235 | } |
| 236 | |
| 237 | /* |
| 238 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 239 | % % |
| 240 | % % |
| 241 | % % |
| 242 | % M a g i c k C l e a r E x c e p t i o n % |
| 243 | % % |
| 244 | % % |
| 245 | % % |
| 246 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 247 | % |
| 248 | % MagickClearException() clears any exceptions associated with the wand. |
| 249 | % |
| 250 | % The format of the MagickClearException method is: |
| 251 | % |
| 252 | % MagickBooleanType MagickClearException(MagickWand *wand) |
| 253 | % |
| 254 | % A description of each parameter follows: |
| 255 | % |
| 256 | % o wand: the magick wand. |
| 257 | % |
| 258 | */ |
| 259 | WandExport MagickBooleanType MagickClearException(MagickWand *wand) |
| 260 | { |
| 261 | assert(wand != (MagickWand *) NULL); |
| 262 | assert(wand->signature == WandSignature); |
| 263 | if (wand->debug != MagickFalse) |
| 264 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 265 | ClearMagickException(wand->exception); |
| 266 | return(MagickTrue); |
| 267 | } |
| 268 | |
| 269 | /* |
| 270 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 271 | % % |
| 272 | % % |
| 273 | % % |
| 274 | % M a g i c k G e t E x c e p t i o n % |
| 275 | % % |
| 276 | % % |
| 277 | % % |
| 278 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 279 | % |
| 280 | % MagickGetException() returns the severity, reason, and description of any |
| 281 | % error that occurs when using other methods in this API. |
| 282 | % |
| 283 | % The format of the MagickGetException method is: |
| 284 | % |
| 285 | % char *MagickGetException(const MagickWand *wand,ExceptionType *severity) |
| 286 | % |
| 287 | % A description of each parameter follows: |
| 288 | % |
| 289 | % o wand: the magick wand. |
| 290 | % |
| 291 | % o severity: the severity of the error is returned here. |
| 292 | % |
| 293 | */ |
| 294 | WandExport char *MagickGetException(const MagickWand *wand, |
| 295 | ExceptionType *severity) |
| 296 | { |
| 297 | char |
| 298 | *description; |
| 299 | |
| 300 | assert(wand != (const MagickWand *) NULL); |
| 301 | assert(wand->signature == WandSignature); |
| 302 | if (wand->debug != MagickFalse) |
| 303 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 304 | assert(severity != (ExceptionType *) NULL); |
| 305 | *severity=wand->exception->severity; |
| 306 | description=(char *) AcquireQuantumMemory(2UL*MaxTextExtent, |
| 307 | sizeof(*description)); |
| 308 | if (description == (char *) NULL) |
| 309 | { |
| 310 | (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, |
| 311 | "MemoryAllocationFailed","`%s'",wand->name); |
| 312 | return((char *) NULL); |
| 313 | } |
| 314 | *description='\0'; |
| 315 | if (wand->exception->reason != (char *) NULL) |
| 316 | (void) CopyMagickString(description,GetLocaleExceptionMessage( |
| 317 | wand->exception->severity,wand->exception->reason),MaxTextExtent); |
| 318 | if (wand->exception->description != (char *) NULL) |
| 319 | { |
| 320 | (void) ConcatenateMagickString(description," (",MaxTextExtent); |
| 321 | (void) ConcatenateMagickString(description,GetLocaleExceptionMessage( |
| 322 | wand->exception->severity,wand->exception->description),MaxTextExtent); |
| 323 | (void) ConcatenateMagickString(description,")",MaxTextExtent); |
| 324 | } |
| 325 | return(description); |
| 326 | } |
| 327 | |
| 328 | /* |
| 329 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 330 | % % |
| 331 | % % |
| 332 | % % |
anthony | fd706f9 | 2012-01-19 04:22:02 +0000 | [diff] [blame] | 333 | % M a g i c k G e t E x c e p t i o n T y p e % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 334 | % % |
| 335 | % % |
| 336 | % % |
| 337 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 338 | % |
| 339 | % MagickGetExceptionType() returns the exception type associated with the |
| 340 | % wand. If no exception has occurred, UndefinedExceptionType is returned. |
| 341 | % |
| 342 | % The format of the MagickGetExceptionType method is: |
| 343 | % |
| 344 | % ExceptionType MagickGetExceptionType(const MagickWand *wand) |
| 345 | % |
| 346 | % A description of each parameter follows: |
| 347 | % |
| 348 | % o wand: the magick wand. |
| 349 | % |
| 350 | */ |
| 351 | WandExport ExceptionType MagickGetExceptionType(const MagickWand *wand) |
| 352 | { |
| 353 | assert(wand != (MagickWand *) NULL); |
| 354 | assert(wand->signature == WandSignature); |
| 355 | if (wand->debug != MagickFalse) |
| 356 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 357 | return(wand->exception->severity); |
| 358 | } |
| 359 | |
| 360 | /* |
| 361 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 362 | % % |
| 363 | % % |
| 364 | % % |
| 365 | % M a g i c k G e t I t e r a t o r I n d e x % |
| 366 | % % |
| 367 | % % |
| 368 | % % |
| 369 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 370 | % |
| 371 | % MagickGetIteratorIndex() returns the position of the iterator in the image |
| 372 | % list. |
| 373 | % |
| 374 | % The format of the MagickGetIteratorIndex method is: |
| 375 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 376 | % ssize_t MagickGetIteratorIndex(MagickWand *wand) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 377 | % |
| 378 | % A description of each parameter follows: |
| 379 | % |
| 380 | % o wand: the magick wand. |
| 381 | % |
| 382 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 383 | WandExport ssize_t MagickGetIteratorIndex(MagickWand *wand) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 384 | { |
| 385 | assert(wand != (MagickWand *) NULL); |
| 386 | assert(wand->signature == WandSignature); |
| 387 | if (wand->debug != MagickFalse) |
| 388 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 389 | if (wand->images == (Image *) NULL) |
| 390 | { |
| 391 | (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, |
| 392 | "ContainsNoIterators","`%s'",wand->name); |
| 393 | return(-1); |
| 394 | } |
| 395 | return(GetImageIndexInList(wand->images)); |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 400 | % % |
| 401 | % % |
| 402 | % % |
| 403 | % 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 % |
| 404 | % % |
| 405 | % % |
| 406 | % % |
| 407 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 408 | % |
| 409 | % MagickQueryConfigureOption() returns the value associated with the specified |
| 410 | % configure option. |
| 411 | % |
| 412 | % The format of the MagickQueryConfigureOption function is: |
| 413 | % |
| 414 | % char *MagickQueryConfigureOption(const char *option) |
| 415 | % |
| 416 | % A description of each parameter follows: |
| 417 | % |
| 418 | % o option: the option name. |
| 419 | % |
| 420 | */ |
| 421 | WandExport char *MagickQueryConfigureOption(const char *option) |
| 422 | { |
| 423 | char |
| 424 | *value; |
| 425 | |
| 426 | const ConfigureInfo |
| 427 | **configure_info; |
| 428 | |
| 429 | ExceptionInfo |
| 430 | *exception; |
| 431 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 432 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 433 | number_options; |
| 434 | |
| 435 | exception=AcquireExceptionInfo(); |
| 436 | configure_info=GetConfigureInfoList(option,&number_options,exception); |
| 437 | exception=DestroyExceptionInfo(exception); |
| 438 | if (configure_info == (const ConfigureInfo **) NULL) |
| 439 | return((char *) NULL); |
| 440 | value=AcquireString(configure_info[0]->value); |
| 441 | configure_info=(const ConfigureInfo **) |
| 442 | RelinquishMagickMemory((void *) configure_info); |
| 443 | return(value); |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 448 | % % |
| 449 | % % |
| 450 | % % |
| 451 | % 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 % |
| 452 | % % |
| 453 | % % |
| 454 | % % |
| 455 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 456 | % |
| 457 | % MagickQueryConfigureOptions() returns any configure options that match the |
| 458 | % specified pattern (e.g. "*" for all). Options include NAME, VERSION, |
| 459 | % LIB_VERSION, etc. |
| 460 | % |
| 461 | % The format of the MagickQueryConfigureOptions function is: |
| 462 | % |
| 463 | % char **MagickQueryConfigureOptions(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 464 | % size_t *number_options) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 465 | % |
| 466 | % A description of each parameter follows: |
| 467 | % |
| 468 | % o pattern: Specifies a pointer to a text string containing a pattern. |
| 469 | % |
| 470 | % o number_options: Returns the number of configure options in the list. |
| 471 | % |
| 472 | % |
| 473 | */ |
| 474 | WandExport char **MagickQueryConfigureOptions(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 475 | size_t *number_options) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 476 | { |
| 477 | char |
| 478 | **options; |
| 479 | |
| 480 | ExceptionInfo |
| 481 | *exception; |
| 482 | |
| 483 | exception=AcquireExceptionInfo(); |
| 484 | options=GetConfigureList(pattern,number_options,exception); |
| 485 | exception=DestroyExceptionInfo(exception); |
| 486 | return(options); |
| 487 | } |
| 488 | |
| 489 | /* |
| 490 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 491 | % % |
| 492 | % % |
| 493 | % % |
| 494 | % M a g i c k Q u e r y F o n t M e t r i c s % |
| 495 | % % |
| 496 | % % |
| 497 | % % |
| 498 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 499 | % |
| 500 | % MagickQueryFontMetrics() returns a 13 element array representing the |
| 501 | % following font metrics: |
| 502 | % |
| 503 | % Element Description |
| 504 | % ------------------------------------------------- |
| 505 | % 0 character width |
| 506 | % 1 character height |
| 507 | % 2 ascender |
| 508 | % 3 descender |
| 509 | % 4 text width |
| 510 | % 5 text height |
| 511 | % 6 maximum horizontal advance |
| 512 | % 7 bounding box: x1 |
| 513 | % 8 bounding box: y1 |
| 514 | % 9 bounding box: x2 |
| 515 | % 10 bounding box: y2 |
| 516 | % 11 origin: x |
| 517 | % 12 origin: y |
| 518 | % |
| 519 | % The format of the MagickQueryFontMetrics method is: |
| 520 | % |
| 521 | % double *MagickQueryFontMetrics(MagickWand *wand, |
| 522 | % const DrawingWand *drawing_wand,const char *text) |
| 523 | % |
| 524 | % A description of each parameter follows: |
| 525 | % |
| 526 | % o wand: the Magick wand. |
| 527 | % |
| 528 | % o drawing_wand: the drawing wand. |
| 529 | % |
| 530 | % o text: the text. |
| 531 | % |
| 532 | */ |
| 533 | WandExport double *MagickQueryFontMetrics(MagickWand *wand, |
| 534 | const DrawingWand *drawing_wand,const char *text) |
| 535 | { |
| 536 | double |
| 537 | *font_metrics; |
| 538 | |
| 539 | DrawInfo |
| 540 | *draw_info; |
| 541 | |
| 542 | MagickBooleanType |
| 543 | status; |
| 544 | |
| 545 | TypeMetric |
| 546 | metrics; |
| 547 | |
| 548 | assert(wand != (MagickWand *) NULL); |
| 549 | assert(wand->signature == WandSignature); |
| 550 | if (wand->debug != MagickFalse) |
| 551 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 552 | assert(drawing_wand != (const DrawingWand *) NULL); |
| 553 | if (wand->images == (Image *) NULL) |
| 554 | { |
| 555 | (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, |
| 556 | "ContainsNoImages","`%s'",wand->name); |
| 557 | return((double *) NULL); |
| 558 | } |
| 559 | font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics)); |
| 560 | if (font_metrics == (double *) NULL) |
| 561 | return((double *) NULL); |
| 562 | draw_info=PeekDrawingWand(drawing_wand); |
| 563 | if (draw_info == (DrawInfo *) NULL) |
| 564 | { |
| 565 | font_metrics=(double *) RelinquishMagickMemory(font_metrics); |
| 566 | return((double *) NULL); |
| 567 | } |
| 568 | (void) CloneString(&draw_info->text,text); |
| 569 | (void) ResetMagickMemory(&metrics,0,sizeof(metrics)); |
cristy | cad4e1b | 2011-10-16 14:58:39 +0000 | [diff] [blame] | 570 | status=GetTypeMetrics(wand->images,draw_info,&metrics,wand->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 571 | draw_info=DestroyDrawInfo(draw_info); |
| 572 | if (status == MagickFalse) |
| 573 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 574 | font_metrics=(double *) RelinquishMagickMemory(font_metrics); |
| 575 | return((double *) NULL); |
| 576 | } |
| 577 | font_metrics[0]=metrics.pixels_per_em.x; |
| 578 | font_metrics[1]=metrics.pixels_per_em.y; |
| 579 | font_metrics[2]=metrics.ascent; |
| 580 | font_metrics[3]=metrics.descent; |
| 581 | font_metrics[4]=metrics.width; |
| 582 | font_metrics[5]=metrics.height; |
| 583 | font_metrics[6]=metrics.max_advance; |
| 584 | font_metrics[7]=metrics.bounds.x1; |
| 585 | font_metrics[8]=metrics.bounds.y1; |
| 586 | font_metrics[9]=metrics.bounds.x2; |
| 587 | font_metrics[10]=metrics.bounds.y2; |
| 588 | font_metrics[11]=metrics.origin.x; |
| 589 | font_metrics[12]=metrics.origin.y; |
| 590 | return(font_metrics); |
| 591 | } |
| 592 | |
| 593 | /* |
| 594 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 595 | % % |
| 596 | % % |
| 597 | % % |
| 598 | % 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 % |
| 599 | % % |
| 600 | % % |
| 601 | % % |
| 602 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 603 | % |
| 604 | % MagickQueryMultilineFontMetrics() returns a 13 element array representing the |
| 605 | % following font metrics: |
| 606 | % |
| 607 | % Element Description |
| 608 | % ------------------------------------------------- |
| 609 | % 0 character width |
| 610 | % 1 character height |
| 611 | % 2 ascender |
| 612 | % 3 descender |
| 613 | % 4 text width |
| 614 | % 5 text height |
| 615 | % 6 maximum horizontal advance |
| 616 | % 7 bounding box: x1 |
| 617 | % 8 bounding box: y1 |
| 618 | % 9 bounding box: x2 |
| 619 | % 10 bounding box: y2 |
| 620 | % 11 origin: x |
| 621 | % 12 origin: y |
| 622 | % |
| 623 | % This method is like MagickQueryFontMetrics() but it returns the maximum text |
| 624 | % width and height for multiple lines of text. |
| 625 | % |
| 626 | % The format of the MagickQueryFontMetrics method is: |
| 627 | % |
| 628 | % double *MagickQueryMultilineFontMetrics(MagickWand *wand, |
| 629 | % const DrawingWand *drawing_wand,const char *text) |
| 630 | % |
| 631 | % A description of each parameter follows: |
| 632 | % |
| 633 | % o wand: the Magick wand. |
| 634 | % |
| 635 | % o drawing_wand: the drawing wand. |
| 636 | % |
| 637 | % o text: the text. |
| 638 | % |
| 639 | */ |
| 640 | WandExport double *MagickQueryMultilineFontMetrics(MagickWand *wand, |
| 641 | const DrawingWand *drawing_wand,const char *text) |
| 642 | { |
| 643 | double |
| 644 | *font_metrics; |
| 645 | |
| 646 | DrawInfo |
| 647 | *draw_info; |
| 648 | |
| 649 | MagickBooleanType |
| 650 | status; |
| 651 | |
| 652 | TypeMetric |
| 653 | metrics; |
| 654 | |
| 655 | assert(wand != (MagickWand *) NULL); |
| 656 | assert(wand->signature == WandSignature); |
| 657 | if (wand->debug != MagickFalse) |
| 658 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 659 | assert(drawing_wand != (const DrawingWand *) NULL); |
| 660 | if (wand->images == (Image *) NULL) |
| 661 | { |
| 662 | (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, |
| 663 | "ContainsNoImages","`%s'",wand->name); |
| 664 | return((double *) NULL); |
| 665 | } |
| 666 | font_metrics=(double *) AcquireQuantumMemory(13UL,sizeof(*font_metrics)); |
| 667 | if (font_metrics == (double *) NULL) |
| 668 | return((double *) NULL); |
| 669 | draw_info=PeekDrawingWand(drawing_wand); |
| 670 | if (draw_info == (DrawInfo *) NULL) |
| 671 | { |
| 672 | font_metrics=(double *) RelinquishMagickMemory(font_metrics); |
| 673 | return((double *) NULL); |
| 674 | } |
| 675 | (void) CloneString(&draw_info->text,text); |
| 676 | (void) ResetMagickMemory(&metrics,0,sizeof(metrics)); |
cristy | 5cbc016 | 2011-08-29 00:36:28 +0000 | [diff] [blame] | 677 | status=GetMultilineTypeMetrics(wand->images,draw_info,&metrics, |
cristy | cad4e1b | 2011-10-16 14:58:39 +0000 | [diff] [blame] | 678 | wand->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 679 | draw_info=DestroyDrawInfo(draw_info); |
| 680 | if (status == MagickFalse) |
| 681 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 682 | font_metrics=(double *) RelinquishMagickMemory(font_metrics); |
| 683 | return((double *) NULL); |
| 684 | } |
| 685 | font_metrics[0]=metrics.pixels_per_em.x; |
| 686 | font_metrics[1]=metrics.pixels_per_em.y; |
| 687 | font_metrics[2]=metrics.ascent; |
| 688 | font_metrics[3]=metrics.descent; |
| 689 | font_metrics[4]=metrics.width; |
| 690 | font_metrics[5]=metrics.height; |
| 691 | font_metrics[6]=metrics.max_advance; |
| 692 | font_metrics[7]=metrics.bounds.x1; |
| 693 | font_metrics[8]=metrics.bounds.y1; |
| 694 | font_metrics[9]=metrics.bounds.x2; |
| 695 | font_metrics[10]=metrics.bounds.y2; |
| 696 | font_metrics[11]=metrics.origin.x; |
| 697 | font_metrics[12]=metrics.origin.y; |
| 698 | return(font_metrics); |
| 699 | } |
| 700 | |
| 701 | /* |
| 702 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 703 | % % |
| 704 | % % |
| 705 | % % |
| 706 | % M a g i c k Q u e r y F o n t s % |
| 707 | % % |
| 708 | % % |
| 709 | % % |
| 710 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 711 | % |
| 712 | % MagickQueryFonts() returns any font that match the specified pattern (e.g. |
| 713 | % "*" for all). |
| 714 | % |
| 715 | % The format of the MagickQueryFonts function is: |
| 716 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 717 | % char **MagickQueryFonts(const char *pattern,size_t *number_fonts) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 718 | % |
| 719 | % A description of each parameter follows: |
| 720 | % |
| 721 | % o pattern: Specifies a pointer to a text string containing a pattern. |
| 722 | % |
| 723 | % o number_fonts: Returns the number of fonts in the list. |
| 724 | % |
| 725 | % |
| 726 | */ |
| 727 | WandExport char **MagickQueryFonts(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 728 | size_t *number_fonts) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 729 | { |
| 730 | char |
| 731 | **fonts; |
| 732 | |
| 733 | ExceptionInfo |
| 734 | *exception; |
| 735 | |
| 736 | exception=AcquireExceptionInfo(); |
| 737 | fonts=GetTypeList(pattern,number_fonts,exception); |
| 738 | exception=DestroyExceptionInfo(exception); |
| 739 | return(fonts); |
| 740 | } |
| 741 | |
| 742 | /* |
| 743 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 744 | % % |
| 745 | % % |
| 746 | % % |
| 747 | % M a g i c k Q u e r y F o r m a t s % |
| 748 | % % |
| 749 | % % |
| 750 | % % |
| 751 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 752 | % |
| 753 | % MagickQueryFonts() returns any image formats that match the specified |
| 754 | % pattern (e.g. "*" for all). |
| 755 | % |
| 756 | % The format of the MagickQueryFonts function is: |
| 757 | % |
| 758 | % char **MagickQueryFonts(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 759 | % size_t *number_formats) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 760 | % |
| 761 | % A description of each parameter follows: |
| 762 | % |
| 763 | % o pattern: Specifies a pointer to a text string containing a pattern. |
| 764 | % |
| 765 | % o number_formats: This integer returns the number of image formats in the |
| 766 | % list. |
| 767 | % |
| 768 | */ |
| 769 | WandExport char **MagickQueryFormats(const char *pattern, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 770 | size_t *number_formats) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 771 | { |
| 772 | char |
| 773 | **formats; |
| 774 | |
| 775 | ExceptionInfo |
| 776 | *exception; |
| 777 | |
| 778 | exception=AcquireExceptionInfo(); |
| 779 | formats=GetMagickList(pattern,number_formats,exception); |
| 780 | exception=DestroyExceptionInfo(exception); |
| 781 | return(formats); |
| 782 | } |
| 783 | |
| 784 | /* |
| 785 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 786 | % % |
| 787 | % % |
| 788 | % % |
| 789 | % M a g i c k R e l i n q u i s h M e m o r y % |
| 790 | % % |
| 791 | % % |
| 792 | % % |
| 793 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 794 | % |
| 795 | % MagickRelinquishMemory() relinquishes memory resources returned by such |
| 796 | % methods as MagickIdentifyImage(), MagickGetException(), etc. |
| 797 | % |
| 798 | % The format of the MagickRelinquishMemory method is: |
| 799 | % |
| 800 | % void *MagickRelinquishMemory(void *resource) |
| 801 | % |
| 802 | % A description of each parameter follows: |
| 803 | % |
| 804 | % o resource: Relinquish the memory associated with this resource. |
| 805 | % |
| 806 | */ |
| 807 | WandExport void *MagickRelinquishMemory(void *memory) |
| 808 | { |
| 809 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 810 | return(RelinquishMagickMemory(memory)); |
| 811 | } |
| 812 | |
| 813 | /* |
| 814 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 815 | % % |
| 816 | % % |
| 817 | % % |
| 818 | % M a g i c k R e s e t I t e r a t o r % |
| 819 | % % |
| 820 | % % |
| 821 | % % |
| 822 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 823 | % |
| 824 | % MagickResetIterator() resets the wand iterator. Use it in conjunction |
| 825 | % with MagickNextImage() to iterate over all the images in a wand |
| 826 | % container. |
| 827 | % |
| 828 | % The format of the MagickResetIterator method is: |
| 829 | % |
| 830 | % void MagickResetIterator(MagickWand *wand) |
| 831 | % |
| 832 | % A description of each parameter follows: |
| 833 | % |
| 834 | % o wand: the magick wand. |
| 835 | % |
| 836 | */ |
| 837 | WandExport void MagickResetIterator(MagickWand *wand) |
| 838 | { |
| 839 | assert(wand != (MagickWand *) NULL); |
| 840 | assert(wand->signature == WandSignature); |
| 841 | if (wand->debug != MagickFalse) |
| 842 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 843 | wand->images=GetFirstImageInList(wand->images); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 844 | wand->set_first=MagickFalse; /* we did not jump to the first image */ |
| 845 | wand->image_pending=MagickTrue; /* this image is the 'next' image */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /* |
| 849 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 850 | % % |
| 851 | % % |
| 852 | % % |
| 853 | % M a g i c k S e t F i r s t I t e r a t o r % |
| 854 | % % |
| 855 | % % |
| 856 | % % |
| 857 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 858 | % |
| 859 | % MagickSetFirstIterator() sets the wand iterator to the first image. |
| 860 | % |
| 861 | % The format of the MagickSetFirstIterator method is: |
| 862 | % |
| 863 | % void MagickSetFirstIterator(MagickWand *wand) |
| 864 | % |
| 865 | % A description of each parameter follows: |
| 866 | % |
| 867 | % o wand: the magick wand. |
| 868 | % |
| 869 | */ |
| 870 | WandExport void MagickSetFirstIterator(MagickWand *wand) |
| 871 | { |
| 872 | assert(wand != (MagickWand *) NULL); |
| 873 | assert(wand->signature == WandSignature); |
| 874 | if (wand->debug != MagickFalse) |
| 875 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 876 | wand->images=GetFirstImageInList(wand->images); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 877 | wand->set_first=MagickTrue; /* we jumped to the first image */ |
| 878 | wand->image_pending=MagickFalse; /* but this image is not 'next' */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | /* |
| 882 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 883 | % % |
| 884 | % % |
| 885 | % % |
| 886 | % M a g i c k S e t I t e r a t o r I n d e x % |
| 887 | % % |
| 888 | % % |
| 889 | % % |
| 890 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 891 | % |
| 892 | % MagickSetIteratorIndex() set the iterator to the position in the image list |
| 893 | % specified with the index parameter. |
| 894 | % |
| 895 | % The format of the MagickSetIteratorIndex method is: |
| 896 | % |
| 897 | % MagickBooleanType MagickSetIteratorIndex(MagickWand *wand, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 898 | % const ssize_t index) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 899 | % |
| 900 | % A description of each parameter follows: |
| 901 | % |
| 902 | % o wand: the magick wand. |
| 903 | % |
| 904 | % o index: the scene number. |
| 905 | % |
| 906 | */ |
| 907 | WandExport MagickBooleanType MagickSetIteratorIndex(MagickWand *wand, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 908 | const ssize_t index) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 909 | { |
| 910 | Image |
| 911 | *image; |
| 912 | |
| 913 | assert(wand != (MagickWand *) NULL); |
| 914 | assert(wand->signature == WandSignature); |
| 915 | if (wand->debug != MagickFalse) |
| 916 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 917 | if (wand->images == (Image *) NULL) |
| 918 | return(MagickFalse); |
| 919 | image=GetImageFromList(wand->images,index); |
| 920 | if (image == (Image *) NULL) |
| 921 | { |
cristy | cad4e1b | 2011-10-16 14:58:39 +0000 | [diff] [blame] | 922 | (void) ThrowMagickException(wand->exception,GetMagickModule(),WandError, |
| 923 | "NoSuchImage","`%s'",wand->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 924 | return(MagickFalse); |
| 925 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 926 | wand->images=image; |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 927 | wand->set_first=MagickFalse; /* we are not at very start of list */ |
| 928 | wand->image_pending=MagickFalse; /* but it is not iteration pending */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 929 | return(MagickTrue); |
| 930 | } |
| 931 | /* |
| 932 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 933 | % % |
| 934 | % % |
| 935 | % % |
| 936 | % M a g i c k S e t L a s t I t e r a t o r % |
| 937 | % % |
| 938 | % % |
| 939 | % % |
| 940 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 941 | % |
| 942 | % MagickSetLastIterator() sets the wand iterator to the last image. |
| 943 | % |
| 944 | % The format of the MagickSetLastIterator method is: |
| 945 | % |
| 946 | % void MagickSetLastIterator(MagickWand *wand) |
| 947 | % |
| 948 | % A description of each parameter follows: |
| 949 | % |
| 950 | % o wand: the magick wand. |
| 951 | % |
| 952 | */ |
| 953 | WandExport void MagickSetLastIterator(MagickWand *wand) |
| 954 | { |
| 955 | assert(wand != (MagickWand *) NULL); |
| 956 | assert(wand->signature == WandSignature); |
| 957 | if (wand->debug != MagickFalse) |
| 958 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 959 | wand->images=GetLastImageInList(wand->images); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 960 | wand->set_first=MagickFalse; /* we are not at very start of list */ |
| 961 | wand->image_pending=MagickFalse; /* and is not iteration pending */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | /* |
| 965 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 966 | % % |
| 967 | % % |
| 968 | % % |
| 969 | % M a g i c k W a n d G e n e s i s % |
| 970 | % % |
| 971 | % % |
| 972 | % % |
| 973 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 974 | % |
| 975 | % MagickWandGenesis() initializes the MagickWand environment. |
| 976 | % |
| 977 | % The format of the MagickWandGenesis method is: |
| 978 | % |
| 979 | % void MagickWandGenesis(void) |
| 980 | % |
| 981 | */ |
| 982 | WandExport void MagickWandGenesis(void) |
| 983 | { |
| 984 | if (IsMagickInstantiated() == MagickFalse) |
| 985 | MagickCoreGenesis((char *) NULL,MagickFalse); |
| 986 | } |
| 987 | |
| 988 | /* |
| 989 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 990 | % % |
| 991 | % % |
| 992 | % % |
| 993 | % M a g i c k W a n d T e r m i n u s % |
| 994 | % % |
| 995 | % % |
| 996 | % % |
| 997 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 998 | % |
| 999 | % MagickWandTerminus() terminates the MagickWand environment. |
| 1000 | % |
| 1001 | % The format of the MaickWandTerminus method is: |
| 1002 | % |
| 1003 | % void MagickWandTerminus(void) |
| 1004 | % |
| 1005 | */ |
| 1006 | WandExport void MagickWandTerminus(void) |
| 1007 | { |
| 1008 | DestroyWandIds(); |
| 1009 | MagickCoreTerminus(); |
| 1010 | } |
| 1011 | |
| 1012 | /* |
| 1013 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1014 | % % |
| 1015 | % % |
| 1016 | % % |
| 1017 | % N e w M a g i c k W a n d % |
| 1018 | % % |
| 1019 | % % |
| 1020 | % % |
| 1021 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1022 | % |
| 1023 | % NewMagickWand() returns a wand required for all other methods in the API. |
cristy | ae75b04 | 2011-04-17 18:30:49 +0000 | [diff] [blame] | 1024 | % A fatal exception is thrown if there is not enough memory to allocate the |
| 1025 | % wand. Use DestroyMagickWand() to dispose of the wand when it is no longer |
| 1026 | % needed. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1027 | % |
| 1028 | % The format of the NewMagickWand method is: |
| 1029 | % |
| 1030 | % MagickWand *NewMagickWand(void) |
| 1031 | % |
| 1032 | */ |
| 1033 | WandExport MagickWand *NewMagickWand(void) |
| 1034 | { |
| 1035 | const char |
| 1036 | *quantum; |
| 1037 | |
| 1038 | MagickWand |
| 1039 | *wand; |
| 1040 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1041 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1042 | depth; |
| 1043 | |
| 1044 | depth=MAGICKCORE_QUANTUM_DEPTH; |
| 1045 | quantum=GetMagickQuantumDepth(&depth); |
| 1046 | if (depth != MAGICKCORE_QUANTUM_DEPTH) |
| 1047 | ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 1048 | wand=(MagickWand *) AcquireMagickMemory(sizeof(*wand)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1049 | if (wand == (MagickWand *) NULL) |
| 1050 | ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", |
| 1051 | GetExceptionMessage(errno)); |
| 1052 | (void) ResetMagickMemory(wand,0,sizeof(*wand)); |
| 1053 | wand->id=AcquireWandId(); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1054 | (void) FormatLocaleString(wand->name,MaxTextExtent,"%s-%.20g",MagickWandId, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1055 | (double) wand->id); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1056 | wand->images=NewImageList(); |
anthony | a89dd17 | 2011-10-04 13:29:35 +0000 | [diff] [blame] | 1057 | wand->image_info=AcquireImageInfo(); |
| 1058 | wand->quantize_info=(QuantizeInfo *) NULL; /* not used in MagickWand API */ |
| 1059 | wand->draw_info=(DrawInfo *) NULL; /* not used in MagickWand API */ |
| 1060 | wand->exception=AcquireExceptionInfo(); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1061 | wand->debug=IsEventLogging(); |
| 1062 | if (wand->debug != MagickFalse) |
| 1063 | (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); |
| 1064 | wand->signature=WandSignature; |
| 1065 | return(wand); |
| 1066 | } |
| 1067 | |
| 1068 | /* |
| 1069 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1070 | % % |
| 1071 | % % |
| 1072 | % % |
| 1073 | % N e w M a g i c k W a n d F r o m I m a g e % |
| 1074 | % % |
| 1075 | % % |
| 1076 | % % |
| 1077 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1078 | % |
| 1079 | % NewMagickWandFromImage() returns a wand with an image. |
| 1080 | % |
| 1081 | % The format of the NewMagickWandFromImage method is: |
| 1082 | % |
| 1083 | % MagickWand *NewMagickWandFromImage(const Image *image) |
| 1084 | % |
| 1085 | % A description of each parameter follows: |
| 1086 | % |
| 1087 | % o image: the image. |
| 1088 | % |
| 1089 | */ |
| 1090 | WandExport MagickWand *NewMagickWandFromImage(const Image *image) |
| 1091 | { |
| 1092 | MagickWand |
| 1093 | *wand; |
| 1094 | |
| 1095 | wand=NewMagickWand(); |
| 1096 | wand->images=CloneImage(image,0,0,MagickTrue,wand->exception); |
| 1097 | return(wand); |
| 1098 | } |