Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/imageprogs/imageInfo.cxx

Go to the documentation of this file.
00001 // Filename: imageInfo.cxx
00002 // Created by:  drose (13Mar03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "imageInfo.h"
00020 #include "pnmImageHeader.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: ImageInfo::Constructor
00024 //       Access: Public
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 ImageInfo::
00028 ImageInfo() {
00029   set_program_description
00030     ("This program reads the headers of a series of one or more "
00031      "image files and reports the image sizes to standard output.");
00032 }
00033 
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: ImageInfo::run
00036 //       Access: Public
00037 //  Description:
00038 ////////////////////////////////////////////////////////////////////
00039 void ImageInfo::
00040 run() {
00041   Args::const_iterator ai;
00042   for (ai = _filenames.begin(); ai != _filenames.end(); ++ai) {
00043     Filename filename = (*ai);
00044     PNMImageHeader header;
00045     if (!header.read_header(filename)) {
00046       // Could not read the image header.
00047       if (filename.exists()) {
00048         nout << filename << ": could not read image.\n";
00049       } else {
00050         nout << filename << ": does not exist.\n";
00051       }
00052     } else {
00053       // Successfully read the image header.
00054       nout << filename << ": " << header.get_x_size() << " x "
00055            << header.get_y_size() << " x " << header.get_num_channels()
00056            << "\n";
00057     }
00058   }
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: ImageInfo::handle_args
00063 //       Access: Protected, Virtual
00064 //  Description: Does something with the additional arguments on the
00065 //               command line (after all the -options have been
00066 //               parsed).  Returns true if the arguments are good,
00067 //               false otherwise.
00068 ////////////////////////////////////////////////////////////////////
00069 bool ImageInfo::
00070 handle_args(ProgramBase::Args &args) {
00071   if (args.empty()) {
00072     nout << "List one or more image filenames on command line.\n";
00073     return false;
00074   }
00075   _filenames = args;
00076 
00077   return true;
00078 }
00079 
00080 
00081 int main(int argc, char *argv[]) {
00082   ImageInfo prog;
00083   prog.parse_command_line(argc, argv);
00084   prog.run();
00085   return 0;
00086 }

Generated on Fri May 2 03:20:06 2003 for Panda-Tool by doxygen1.3