Magick++  7.0.7
Convert, Edit, Or Compose Bitmap Images
flip.cpp
Go to the documentation of this file.
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 <Magick++.h>
12 #include <string>
13 #include <iostream>
14 #include <list>
15 #include <algorithm>
16 
17 using namespace std;
18 
19 using namespace Magick;
20 
21 int main( int /*argc*/, char ** argv)
22 {
23 
24  // Initialize ImageMagick install location for Windows
25  InitializeMagick(*argv);
26 
27 
28  try {
29 
30  string srcdir("");
31  if(getenv("SRCDIR") != 0)
32  srcdir = getenv("SRCDIR");
33 
34  // Read images into STL list
35  list<Image> imageList;
36  readImages( &imageList, srcdir + "smile_anim.miff" );
37 
38  // cout << "Total scenes: " << imageList.size() << endl;
39 
40  // Flip images
41  for_each( imageList.begin(), imageList.end(), flipImage() );
42 
43  // Create a morphed version, adding three frames between each
44  // existing frame.
45  list<Image> morphed;
46  morphImages( &morphed, imageList.begin(), imageList.end(), 3 );
47 
48  // Write out images
49  cout << "Writing image \"flip_out.miff\" ..." << endl;
50  writeImages( morphed.begin(), morphed.end(), "flip_out.miff" );
51 
52  }
53  catch( exception &error_ )
54  {
55  cout << "Caught exception: " << error_.what() << endl;
56  return 1;
57  }
58 
59  return 0;
60 }
STL namespace.
void writeImages(InputIterator first_, InputIterator last_, const std::string &imageSpec_, bool adjoin_=true)
Definition: STL.h:2746
void readImages(Container *sequence_, const std::string &imageSpec_, ReadOptions &options)
Definition: STL.h:2658
int main(int, char **argv)
Definition: flip.cpp:21
void morphImages(Container *morphedImages_, InputIterator first_, InputIterator last_, size_t frames_)
Definition: STL.h:2513
Definition: Blob.h:15
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:43