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