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,
     27     *input,
     28     *output;
     29 
     30   MagickBooleanType
     31     status;
     32 
     33   printf("Check prepend when using 'FirstIterator' on empty wand\n");
     34   printf("Result shoud be: 3210\n");
     35 
     36   MagickWandGenesis();
     37 
     38   wand = NewMagickWand();
     39 
     40   MagickSetFirstIterator(wand);    /* set first iterator to empty wand */
     41 
     42   status = MagickReadImage(wand, "font_0.gif" );
     43   if (status == MagickFalse)
     44     ThrowWandException(wand);
     45 
     46   status = MagickReadImage(wand, "font_1.gif" );
     47   if (status == MagickFalse)
     48     ThrowWandException(wand);
     49 
     50   status = MagickReadImage(wand, "font_2.gif" );
     51   if (status == MagickFalse)
     52     ThrowWandException(wand);
     53 
     54   status = MagickReadImage(wand, "font_3.gif" );
     55   if (status == MagickFalse)
     56     ThrowWandException(wand);
     57 
     58   /* append all images together to create the output wand */
     59   MagickResetIterator(wand); /* append all images */
     60   output = MagickAppendImages(wand,MagickFalse);
     61   wand = DestroyMagickWand(wand);  /* finished - could swap here */
     62 
     63   /* Final output */
     64   status = MagickWriteImage(output,"show:");
     65   if (status == MagickFalse)
     66     ThrowWandException(output);
     67 
     68   output = DestroyMagickWand(output);
     69 
     70   MagickWandTerminus();
     71 }
     72 
     73