| 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 | MagickPlusPlusGenesis genesis(*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 ( |
| 43 | ( averaged.signature() != "16fac0dc82f3901de623ce9ff991c368f6752acf6cb0c11170d78412c3729730") && |
| 44 | ( averaged.signature() != "6574796b7b07d7400a7a310052eabf2b58f81952d1854a76ac9a23890ac2073b") && |
| 45 | ( averaged.signature() != "ad4861b99339d84bed685eb42bbabe657abb60d48b8fc7ddf680af866dd45ad4") && |
| 46 | ( averaged.signature() != "8e6e1a9b5f1eec5539b1f44347249f227f3e07f9acb07d80404ca6a19f88db7c") && |
| 47 | ( averaged.signature() != "a88e978776d45b73bc8c9f37f6726cc9f14a3118b9a82384ee5acf488c5c2863") && |
| 48 | ( averaged.signature() != "6bda37a8b6734ac271595f5b583d801cfb2479637401d056eae9be97127f558f") && |
| 49 | ( averaged.signature() != "919a9e18a5e5ded83c2c4e5cfcd21d654802fcc14b06b02898d96fe28f04a1a1") |
| 50 | ) |
| 51 | { |
| 52 | cout << "Line: " << __LINE__ |
| 53 | << " Averaging image failed, signature = " |
| 54 | << averaged.signature() << endl; |
| 55 | averaged.display(); |
| 56 | ++failures; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | catch( Exception &error_ ) |
| 61 | { |
| 62 | cout << "Caught exception: " << error_.what() << endl; |
| 63 | return 1; |
| 64 | } |
| 65 | catch( exception &error_ ) |
| 66 | { |
| 67 | cout << "Caught exception: " << error_.what() << endl; |
| 68 | return 1; |
| 69 | } |
| 70 | |
| 71 | if ( failures ) |
| 72 | { |
| 73 | cout << failures << " failures" << endl; |
| 74 | return 1; |
| 75 | } |
| 76 | |
| 77 | return 0; |
| 78 | } |
| 79 |