Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011
00012 #include "nstream/nstream.h"
00013 #include "perf/perf.h"
00014 #include "util/file.h"
00015 #include "wave-image/wave-image.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 int
00026 main
00027 (
00028 IN int argc,
00029 IN const char * argv[]
00030 )
00031 {
00032 ASSERT(2 == argc, "Usage: load-image <image-path>");
00033 const char * filename = argv[1];
00034 DPRINTF("Attempting to load image: '%s'", filename);
00035
00036 int retval = 0;
00037
00038 try {
00039
00040 std::string parent;
00041 GetParentDirectory(filename, parent);
00042 const char * dir = parent.c_str();
00043 if (!*dir) {
00044 dir = ".";
00045 }
00046
00047
00048 smart_ptr<nstream::Manager> mgr =
00049 nstream::getFilesystemManager(dir);
00050 ASSERT(mgr, "failed to get filesystem manager");
00051
00052
00053 const char * name = GetFilename(filename);
00054
00055
00056 media::image_t img;
00057 if (!loadImage(mgr, name, img)) {
00058 WAVE_EX(wex);
00059 wex << "Failed to open image file: " << filename;
00060 }
00061
00062
00063 img.dump(filename);
00064
00065 } catch(std::exception& e) {
00066 DPRINTF("EXCEPTION: %s", e.what());
00067 retval = 1;
00068 }
00069
00070 perf::dumpTimingSummary(std::cerr);
00071
00072 return retval;
00073 }
00074