Home | History | Annotate | Download | only in tests
      1 // This may look like C code, but it is really -*- C++ -*-
      2 //
      3 // Copyright Bob Friesenhahn, 1999, 2000, 2003
      4 //
      5 // Test STL averageImages function
      6 //
      7 
      8 #include <Magick++.h>
      9 #include <string>
     10 #include <iostream>
     11 #include <list>
     12 #include <vector>
     13 
     14 using namespace std;
     15 
     16 using namespace Magick;
     17 
     18 int main( int /*argc*/, char ** argv)
     19 {
     20 
     21   // Initialize ImageMagick install location for Windows
     22   InitializeMagick(*argv);
     23 
     24   int failures=0;
     25 
     26   try {
     27 
     28     string srcdir("");
     29     if(getenv("SRCDIR") != 0)
     30       srcdir = getenv("SRCDIR");
     31 
     32     //
     33     // Test averageImages
     34     //
     35 
     36     list<Image> imageList;
     37     readImages( &imageList, srcdir + "test_image_anim.miff" );
     38 
     39     Image averaged;
     40     averageImages( &averaged, imageList.begin(), imageList.end() );
     41     // averaged.display();
     42     if ( 0 && averaged.signature() != "d4b4ffb8b70c4e9b0e50445542deb26fbcdf8c393c793123cbc92fb35341e44d" &&
     43          averaged.signature() != "62d46d6d239b9fbd3b8ff2271aed1b5dde6303e0d5228dd8d833f61a7b012a79" &&
     44          averaged.signature() != "fdc76a2689d19061e1f7f6adfd79a2c04bc4608125a2cd2a1bce0d981774e13f" &&
     45          averaged.signature() != "66dfb88c21405a6bf582c9a542d87fd14db176aae1f34bc30b0b3e2443b49aa8" &&
     46          averaged.signature() != "f3bc318abc0b842c656b6545d1d7159eedb61f559a95fc5df671db7d0c0639de")
     47       {
     48 	cout << "Line: " << __LINE__
     49 	     << "  Averaging image failed, signature = "
     50 	     << averaged.signature() << endl;
     51 	averaged.display();
     52 	++failures;
     53       }
     54   }
     55 
     56   catch( Exception &error_ )
     57     {
     58       cout << "Caught exception: " << error_.what() << endl;
     59       return 1;
     60     }
     61   catch( exception &error_ )
     62     {
     63       cout << "Caught exception: " << error_.what() << endl;
     64       return 1;
     65     }
     66 
     67   if ( failures )
     68     {
     69       cout << failures << " failures" << endl;
     70       return 1;
     71     }
     72 
     73   return 0;
     74 }
     75 
     76