Home | History | Annotate | Download | only in tests
      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  */
      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 
     23 int main(int argc, char *argv[])
     24 {
     25   MagickWand
     26     *wand,    /* red image wand */
     27     *output;
     28 
     29   MagickBooleanType
     30     status;
     31 
     32   printf("Read 3 sets of 3 Images, each set with settings: none, first, last\n");
     33   printf("Result shoud be: 543 012 678\n");
     34 
     35   MagickWandGenesis();
     36 
     37   /* read in the red image */
     38   wand = NewMagickWand();
     39 
     40   /* add test from empty wand */
     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   /* add test to start */
     54   MagickSetFirstIterator(wand);
     55   status = MagickReadImage(wand, "font_3.gif" );
     56   if (status == MagickFalse)
     57     ThrowWandException(wand);
     58 
     59   status = MagickReadImage(wand, "font_4.gif" );
     60   if (status == MagickFalse)
     61     ThrowWandException(wand);
     62 
     63   status = MagickReadImage(wand, "font_5.gif" );
     64   if (status == MagickFalse)
     65     ThrowWandException(wand);
     66 
     67   /* add test to end */
     68   MagickSetLastIterator(wand);
     69   status = MagickReadImage(wand, "font_6.gif" );
     70   if (status == MagickFalse)
     71     ThrowWandException(wand);
     72 
     73   status = MagickReadImage(wand, "font_7.gif" );
     74   if (status == MagickFalse)
     75     ThrowWandException(wand);
     76 
     77   status = MagickReadImage(wand, "font_8.gif" );
     78   if (status == MagickFalse)
     79     ThrowWandException(wand);
     80 
     81   /* append all images together to create the output wand */
     82   MagickResetIterator(wand); /* append all images */
     83   output = MagickAppendImages(wand,MagickFalse);
     84   wand = DestroyMagickWand(wand);  /* finished - could swap here */
     85 
     86   /* Final output */
     87   status = MagickWriteImage(output,"show:");
     88   if (status == MagickFalse)
     89     ThrowWandException(output);
     90 
     91   output = DestroyMagickWand(output);
     92 
     93   MagickWandTerminus();
     94 }
     95 
     96