ait-survey

xyzrgb16bit->8bit.cpp

Dec 4th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<iomanip>
  4. #include<sstream>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv)
  9. {
  10.  
  11.     if(argc!=3)
  12.     {
  13.         fprintf(stderr,"Usage: %s\n(1)Input_filename\n(2)Output_filename\n",argv[0]);
  14.         //exit(1);
  15.     }
  16.    
  17.     ifstream ifs(argv[1]);
  18.     ofstream ofs(argv[2]);
  19.     string line;
  20.    
  21.     cout << "now converting....wait for a short time" <<endl;
  22.    
  23.     while(getline(ifs,line))
  24.     {
  25.         float x,y,z;
  26.         int r,g,b;
  27.         int r_down,g_down,b_down;
  28.  
  29.         istringstream is(line);
  30.        
  31.         is  >> x >> y >> z >> r >> g >> b;
  32.        
  33.         r_down=r/255;
  34.         g_down=g/255;
  35.         b_down=b/255;
  36.        
  37.         //cout<< x <<" "<< y <<" "<<z<<" "<<r_down<<" "<<g_down<<" "<< b_down<<endl;
  38.         ofs<< x <<" "<< y <<" "<<z<<" "<<r_down<<" "<<g_down<<" "<< b_down<<endl;
  39.  
  40.     }
  41.    
  42.     ifs.close();
  43.     ofs.close();
  44.    
  45.     cout << "finished" << endl;
  46.    
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment