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