1 #include <stdio.h>
2 #include <MagickWand/MagickWand.h>
3
4 /* Simplify the exception handling
5 * technically we should abort the program if
6 * severity >= ErrorException
7 */
ThrowWandException(MagickWand * wand)8 void ThrowWandException(MagickWand *wand)
9 { char
10 *description;
11
12 ExceptionType
13 severity;
14
15 description=MagickGetException(wand,&severity);
16 (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description);
17 description=(char *) MagickRelinquishMemory(description);
18 }
19
20 /* useful function especially after appending two wands together */
21 #define SwapWands(a,b) { MagickWand *tmp=a; a=b; b=tmp; }
22
main(int argc,char * argv[])23 int main(int argc, char *argv[])
24 {
25 MagickWand
26 *wand,
27 *output;
28
29 MagickBooleanType
30 status;
31
32 printf("Check append when using 'LastIterator' on empty wand\n");
33 printf("Result shoud be: 0123\n");
34
35 MagickWandGenesis();
36
37 wand = NewMagickWand();
38
39 MagickSetLastIterator(wand); /* to empty wand */
40
41 status = MagickReadImage(wand, "font_0.gif" );
42 if (status == MagickFalse)
43 ThrowWandException(wand);
44
45 status = MagickReadImage(wand, "font_1.gif" );
46 if (status == MagickFalse)
47 ThrowWandException(wand);
48
49 status = MagickReadImage(wand, "font_2.gif" );
50 if (status == MagickFalse)
51 ThrowWandException(wand);
52
53 status = MagickReadImage(wand, "font_3.gif" );
54 if (status == MagickFalse)
55 ThrowWandException(wand);
56
57 /* append all images together to create the output wand */
58 MagickResetIterator(wand); /* append all images */
59 output = MagickAppendImages(wand,MagickFalse);
60 wand = DestroyMagickWand(wand); /* finished - could swap here */
61
62 /* Final output */
63 status = MagickWriteImage(output,"show:");
64 if (status == MagickFalse)
65 ThrowWandException(output);
66
67 output = DestroyMagickWand(output);
68
69 MagickWandTerminus();
70 }
71
72