]> granicus.if.org Git - imagemagick/blob - Magick++/tests/appendImages.cpp
(no commit message)
[imagemagick] / Magick++ / tests / appendImages.cpp
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2003
4 //
5 // Test STL appendImages 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 appendImages
34     //
35
36     list<Image> imageList;
37     readImages( &imageList, srcdir + "test_image_anim.miff" );
38
39     Image appended;
40
41     // Horizontal
42     appendImages( &appended, imageList.begin(), imageList.end() );
43     // appended.display();
44     if (( appended.signature() != "3a90bb0bb8f69f6788ab99e9e25598a0d6c5cdbbb797f77ad68011e0a8b1689d" ) &&
45         ( appended.signature() != "a251c7b271e711604c800658cf80ad17ef32328ab9b24fca54438b214224c3d9" ) &&
46         ( appended.signature() != "229ff72f812e5f536245dc3b4502a0bc2ab2363f67c545863a85ab91ebfbfb83" ) &&
47         ( appended.signature() != "b98c42c55fc4e661cb3684154256809c03c0c6b53da2738b6ce8066e1b6ddef0" ))
48       {
49         ++failures;
50         cout << "Line: " << __LINE__
51              << "  Horizontal append failed, signature = "
52              << appended.signature() << endl;
53         appended.write("appendImages_horizontal_out.miff");
54         // appended.display();
55       }
56
57     // Vertical
58     appendImages( &appended, imageList.begin(), imageList.end(), true );
59     if (( appended.signature() != "d73d25ccd6011936d08b6d0d89183b7a61790544c2195269aff4db2f782ffc08" ) &&
60         ( appended.signature() != "a251c7b271e711604c800658cf80ad17ef32328ab9b24fca54438b214224c3d9" ) &&
61         ( appended.signature() != "11b97ba6ac1664aa1c2faed4c86195472ae9cce2ed75402d975bb4ffcf1de751" ) &&
62         ( appended.signature() != "cae4815eeb3cb689e73b94d897a9957d3414d1d4f513e8b5e52579b05d164bfe" ))
63       {
64         ++failures;
65         cout << "Line: " << __LINE__
66              << "  Vertical append failed, signature = "
67              << appended.signature() << endl;
68         appended.write("appendImages_vertical_out.miff");
69         // appended.display();
70       }
71     
72   }
73
74   catch( Exception &error_ )
75     {
76       cout << "Caught exception: " << error_.what() << endl;
77       return 1;
78     }
79   catch( exception &error_ )
80     {
81       cout << "Caught exception: " << error_.what() << endl;
82       return 1;
83     }
84
85   if ( failures )
86     {
87       cout << failures << " failures" << endl;
88       return 1;
89     }
90   
91   return 0;
92 }
93