flip.cpp revision d9eec389c7cc5509499adbae12fd7a129914a732
1// This may look like C code, but it is really -*- C++ -*- 2// 3// Copyright Bob Friesenhahn, 1999, 2003 4// 5// Demonstration of unary function-object based operations 6// 7// Reads the multi-frame file "smile_anim.miff" and writes a 8// flipped and morphed version to "flip_out.miff". 9// 10 11#include <cstring> 12#include <Magick++.h> 13#include <string> 14#include <iostream> 15#include <list> 16#include <algorithm> 17 18using namespace std; 19 20using namespace Magick; 21 22int main( int /*argc*/, char ** argv) 23{ 24 25 // Initialize ImageMagick install location for Windows 26 InitializeMagick(*argv); 27 28 29 try { 30 31 string srcdir(""); 32 if(getenv("SRCDIR") != 0) 33 srcdir = getenv("SRCDIR"); 34 35 // Read images into STL list 36 list<Image> imageList; 37 readImages( &imageList, srcdir + "smile_anim.miff" ); 38 39 // cout << "Total scenes: " << imageList.size() << endl; 40 41 // Flip images 42 for_each( imageList.begin(), imageList.end(), flipImage() ); 43 44 // Create a morphed version, adding three frames between each 45 // existing frame. 46 list<Image> morphed; 47 morphImages( &morphed, imageList.begin(), imageList.end(), 3 ); 48 49 // Write out images 50 cout << "Writing image \"flip_out.miff\" ..." << endl; 51 writeImages( morphed.begin(), morphed.end(), "flip_out.miff" ); 52 53 } 54 catch( exception &error_ ) 55 { 56 cout << "Caught exception: " << error_.what() << endl; 57 return 1; 58 } 59 60 return 0; 61} 62