Magick++  7.1.0
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 // 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 
20 using namespace std;
21 
22 using namespace Magick;
23 
24 int 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 }
STL namespace.
void writeImages(InputIterator first_, InputIterator last_, const std::string &imageSpec_, bool adjoin_=true)
Definition: STL.h:2823
void readImages(Container *sequence_, const std::string &imageSpec_, ReadOptions &options)
Definition: STL.h:2735
int main(int, char **argv)
Definition: flip.cpp:24
void morphImages(Container *morphedImages_, InputIterator first_, InputIterator last_, size_t frames_)
Definition: STL.h:2538
Definition: Blob.h:17
MagickPPExport void InitializeMagick(const char *path_)
Definition: Functions.cpp:45