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("Just read images in three groups, no settings used\n");
     34   printf("Result shoud be: 012 345 678\n");
     35 
     36   MagickWandGenesis();
     37 
     38   wand = NewMagickWand();
     39   input = NewMagickWand();
     40 
     41   status = MagickReadImage(input, "font_0.gif" )
     42         && MagickReadImage(input, "font_1.gif" )
     43         && MagickReadImage(input, "font_2.gif" );
     44   if (status == MagickFalse)
     45     ThrowWandException(input);
     46 
     47   status = MagickAddImage(wand, input);
     48   if (status == MagickFalse)
     49     ThrowWandException(wand);
     50 
     51   ClearMagickWand(input);
     52   status = MagickReadImage(input, "font_3.gif" )
     53         && MagickReadImage(input, "font_4.gif" )
     54         && MagickReadImage(input, "font_5.gif" );
     55   if (status == MagickFalse)
     56     ThrowWandException(input);
     57 
     58   status = MagickAddImage(wand, input);
     59   if (status == MagickFalse)
     60     ThrowWandException(wand);
     61   ClearMagickWand(input);
     62 
     63   ClearMagickWand(input);
     64   status = MagickReadImage(input, "font_6.gif" )
     65         && MagickReadImage(input, "font_7.gif" )
     66         && MagickReadImage(input, "font_8.gif" );
     67   if (status == MagickFalse)
     68     ThrowWandException(input);
     69 
     70   status = MagickAddImage(wand, input);
     71   if (status == MagickFalse)
     72     ThrowWandException(wand);
     73   input=DestroyMagickWand(input);
     74 
     75   /* append all images together to create the output wand */
     76   MagickResetIterator(wand); /* append all images */
     77   output = MagickAppendImages(wand,MagickFalse);
     78   wand = DestroyMagickWand(wand);  /* finished - could swap here */
     79 
     80   /* Final output */
     81   status = MagickWriteImage(output,"show:");
     82   if (status == MagickFalse)
     83     ThrowWandException(output);
     84 
     85   output = DestroyMagickWand(output);
     86 
     87   MagickWandTerminus();
     88 }
     89 
     90