Advertisement
Guest User

for_the_film_year

a guest
Feb 7th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <Magick++.h>
  2. #include <cassert>
  3. #include <vector>
  4. #include <glob.h>
  5. #include <iostream>
  6. #include <fstream>
  7. #include <sstream>
  8.  
  9. using namespace std;
  10. using namespace Magick;
  11.  
  12. int main(int argc,char **argv)
  13. {
  14.     glob_t pics;
  15.     glob("*.jpg",GLOB_MARK,NULL,&pics);
  16.     InitializeMagick(*argv);
  17.     vector<Image> im;
  18.     for(int i = 0; i < pics.gl_pathc; ++i){
  19.         try
  20.         {
  21.             Image newim(pics.gl_pathv[i]);
  22.             newim.resize("1000x480");
  23.             im.push_back(newim);
  24.             while(im.size() > 639){
  25.                 ostringstream oss;
  26.                 oss << "im" << i+360 << ".jpg";
  27.                 Image out("640x480", "white");
  28.                 out.type(TrueColorType);
  29.                 out.modifyImage();
  30.                 ssize_t x = 0;
  31.                 for(vector<Image>::iterator it = im.begin(); it != im.end(); ++it){
  32.                     assert(it->columns() >= 640);
  33.                     assert(it->rows() >= 480);
  34.                     assert(out.columns() >= 640);
  35.                     assert(out.rows() >= 480);
  36.                     assert(x < 640);
  37.                     PixelPacket *in_cache = it->getPixels(x,0,1,480);
  38.                     PixelPacket *out_cache = out.getPixels(x,0,1,480);
  39.                     for(int p = 0; p < 480; ++p) out_cache[p] = in_cache[p];
  40.                     out.syncPixels();
  41.                     ++x;
  42.                     if(x > 639) break;
  43.                 }
  44.                 out.write(oss.str());
  45.                 im.erase(im.begin());
  46.             }
  47.         }
  48.         catch( Exception &error_ )
  49.         {
  50.             cout << "Caught exception: " << error_.what() << endl;
  51.             return 1;
  52.         }
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement