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 */ 8void 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 23int main(int argc, char *argv[]) 24{ 25 MagickWand 26 *wand, 27 *output; 28 29 MagickBooleanType 30 status; 31 32 printf("Just read images one at a time, no settings\n"); 33 printf("Result shoud be: 0123\n"); 34 35 MagickWandGenesis(); 36 37 wand = NewMagickWand(); 38 39 status = MagickReadImage(wand, "font_0.gif" ); 40 if (status == MagickFalse) 41 ThrowWandException(wand); 42 43 status = MagickReadImage(wand, "font_1.gif" ); 44 if (status == MagickFalse) 45 ThrowWandException(wand); 46 47 status = MagickReadImage(wand, "font_2.gif" ); 48 if (status == MagickFalse) 49 ThrowWandException(wand); 50 51 status = MagickReadImage(wand, "font_3.gif" ); 52 if (status == MagickFalse) 53 ThrowWandException(wand); 54 55 /* append all images together to create the output wand */ 56 MagickResetIterator(wand); /* append all images */ 57 output = MagickAppendImages(wand,MagickFalse); 58 wand = DestroyMagickWand(wand); /* finished - could swap here */ 59 60 /* Final output */ 61 status = MagickWriteImage(output,"show:"); 62 if (status == MagickFalse) 63 ThrowWandException(output); 64 65 output = DestroyMagickWand(output); 66 67 MagickWandTerminus(); 68} 69 70