home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / source / utils / region.cpp < prev    next >
C/C++ Source or Header  |  1995-05-12  |  1KB  |  51 lines

  1. #include <fastgraf.h>
  2. #include <iostream.h>
  3. #include <stdlib.h>
  4. #include <io.h>
  5.  
  6. const int INPUTFILE = 1;
  7. const int OUTPUTFILE = 2;
  8. const int XONE = 3;
  9. const int YONE = 4;
  10. const int XTWO = 5;
  11. const int YTWO = 6;
  12.  
  13. const int VMODE = 22;
  14.  
  15. int main(int argc,char** argv)
  16.   {
  17.   int x1,y1,x2,y2;
  18.   if (argc<7)
  19.     {
  20.     cout << "\nUSAGE : REGION <in_pcx> <out_pcx> <x1> <y1> <x2> <y2>\n\n"; 
  21.     return -1;
  22.     }
  23.   if (access(argv[INPUTFILE],0)!=0)
  24.     {
  25.     cout << "can't find file '" << argv[INPUTFILE] << "'\n";
  26.     return -1;
  27.     }
  28.   x1=atoi(argv[XONE]);
  29.   y1=atoi(argv[YONE]);
  30.   x2=atoi(argv[XTWO]);  
  31.   y2=atoi(argv[YTWO]);
  32.  
  33.   if (!(x1>=0 && y1>=0 && x2-x1<320 && y2-y1<240 && x2-x1>0 && y2-y1>0))
  34.     {
  35.     cout << "input error involving region coordinates\n";
  36.     return -1;
  37.     } 
  38.  
  39.   int oldmode=fg_getmode();
  40.   fg_setmode(VMODE);
  41.  
  42.   fg_move(0,0);
  43.   fg_showpcx(argv[INPUTFILE],2);
  44.  
  45.   fg_makepcx(x1,x2,y1,y2,argv[OUTPUTFILE]);
  46.  
  47.   fg_setmode(oldmode);
  48.   return 0;
  49.   }
  50.  
  51.