#include #include #include #include #include "TargaWindow.h" int main(int argc, char** argv) { // The name of the TGA file to load char* filename = 0; // The name of the TGA file we're going to write char* ofilename = 0; // If there is just one argument, then that argument should // be the TGA file to load if (argc == 2) { filename = argv[1]; } else if (argc == 3) { filename = argv[1]; ofilename = argv[2]; } else if ( argc == 1 ) { // Using a file chooser, allow the user to select a targa // file to manipulate. filename = fl_file_chooser("Pick a targa file","{*.tga}",""); } // If filename exists, not NULL, then the user chose a // targa file to manipulate if (filename) { // Create a TargaWindow of size 300 x 300 TargaWindow a(300,300); // Set the image of the TargaWindow to be the image file // chosen by the user. a.setImage(filename); // Display the window a.show(); // Run FLTK Fl::run(); // When the user exits FLTK ( closes the window ) // Allow the user save the file into a targa file // of their choice. // If the filename is NULL, ask the user to input a filename // for writing out the targa image. if (ofilename == NULL) { const char* outfname = fl_input("Output Filename?",ofilename); if (outfname) a.writeImage(outfname); } else { a.writeImage(ofilename); } } return 1; }