warp_to_png [--size "x y"] <
infile.warp >
outfile.png Definition in file warp_to_png.cc.
#include <iostream>
#include <iterator>
#include <vector>
#include <cstdlib>
#include <cvd/image_io.h>
#include <gvars3/instances.h>
#include "warp_to_png.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Driving function.
argc | Number of command line arguments | |
argv | Commandline argument list |
Definition at line 57 of file warp_to_png.cc.
00058 { 00059 try 00060 { 00061 GUI.parseArguments(argc, argv); 00062 00063 ImageRef size = GV3::get<ImageRef>("size", ImageRef(768,576), 1); 00064 00065 00066 Image<Rgb<unsigned short> > si(size); 00067 00068 for(int y=0; y < size.y; y++) 00069 for(int x=0; x < size.x; x++) 00070 { 00071 float f1, f2; 00072 cin >> f1 >> f2; 00073 00074 if(!cin.good()) 00075 { 00076 cerr << "EOF!\n"; 00077 exit(1); 00078 } 00079 00080 if(f1 < -5 || f1 > 1000) 00081 { 00082 cerr << "Bad value at " << x << ", " << y << ": " << f1; 00083 exit(2); 00084 } 00085 00086 if(f2 < -5 || f2 > 1000) 00087 { 00088 cerr << "Bad value at " << x << ", " << y << ": " << f2; 00089 exit(2); 00090 } 00091 00092 Rgb<unsigned short> o; 00093 00094 o.red = (unsigned short) ((SHIFT + f1)*MULTIPLIER + .5); 00095 o.green = (unsigned short) ((SHIFT + f2)*MULTIPLIER + .5); 00096 o.blue = 0; 00097 00098 si[y][x] = o; 00099 } 00100 00101 img_save(si, cout, ImageType::PNG); 00102 } 00103 catch(Exceptions::All e) 00104 { 00105 cerr << "Error: " << e.what << endl; 00106 return 1; 00107 } 00108 }