OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
image_copy.cpp File Reference
#include <iostream>
#include <iterator>
#include "base/data_types/ossimFilename.h"
#include "base/data_types/ossimString.h"
#include "base/common/ossimStdOutProgress.h"
#include "imaging/factory/ossimImageHandlerRegistry.h"
#include "imaging/formats/ossimImageHandler.h"
#include "imaging/formats/ossimImageFileWriter.h"
#include "imaging/factory/ossimImageWriterFactoryRegistry.h"
#include "init/ossimInit.h"

Go to the source code of this file.

Functions

void usage ()
 
void printOutputTypes ()
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 57 of file image_copy.cpp.

References ossimImageFileWriter::addListener(), ossimConnectableObject::connectMyInputTo(), ossimImageWriterFactoryRegistry::createWriter(), ossimImageFileWriter::execute(), ossimInit::initialize(), ossimImageWriterFactoryRegistry::instance(), ossimInit::instance(), ossimImageHandlerRegistry::instance(), ossimImageHandlerRegistry::open(), ossimImageFileWriter::removeListener(), ossimImageFileWriter::setFilename(), and usage().

58 {
59  ossimInit::instance()->initialize(argc, argv);
60 
61  if(argc!=4)
62  {
63  usage();
64  }
65  else
66  {
67  // try to open up the passed in image
68  //
70 
71  // try to create a writer for the output image type.
72  //
74 
75  if(!handler)
76  {
77  cout << "Unable to open input image: "<< argv[2] << endl;
78  return 1;
79  }
80  if(!writer)
81  {
82  cout << "Unable to create writer of type: " << argv[1] << endl;
83  delete handler;
84  return 1;
85  }
86 
87  // specify the output file name
88  writer->setFilename(ossimFilename(argv[3]));
89 
90  // within OSSIM we have a concept of inputs that can be connected together
91  // writer have only 1 input and we index them starting from 0. If we only
92  // supplied the second argument it would find the first available input and connect
93  // it to that slot. Here, we explicitly say connect the handler to slot 0 of the
94  // writer.
95  //
96  writer->connectMyInputTo(0, handler);
97 
98  // Optionally we can add listeners to listen for certain events.
99  //
100  // all writers should execute event processing and generate a progress event.
101  // we have a default event listener that listens for this event and can be used
102  // to output the progress of the exected process.
103  //
104  // the first argument is to specify the precision of the percent complete
105  // output, here we default to 0 for whole number outputs. The second argument
106  // specifies to flush the stream on each print If you don't want progress
107  // output then don't add this listener
108  //
109  // the defalut standard out listener is found in base/common/ossimStdOutProgress.h"
110  //
111  ossimStdOutProgress progress(0, true);
112  writer->addListener(&progress);
113 
114  // execute the writer. Writer will start sequencing through
115  // all the tiles from the input and output it to disk.
116  //
117  writer->execute();
118 
119  // now to be on the safe side we will remove any added listeners.
120  writer->removeListener(&progress);
121 
122  delete writer;
123  delete handler;
124  }
125 
126  return 0;
127 }
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
virtual bool addListener(ossimListener *listener)
Overrides base "addListener" this will capture the pointer and then call the base class "addListener"...
static ossimImageWriterFactoryRegistry * instance()
Pure virtual base class for image file writers.
void usage()
Definition: image_copy.cpp:130
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
virtual void setFilename(const ossimFilename &file)
This class defines an abstract Handler which all image handlers(loaders) should derive from...
static ossimInit * instance()
Definition: ossimInit.cpp:89
ossimImageFileWriter * createWriter(const ossimFilename &filename) const
static ossimImageHandlerRegistry * instance()
virtual bool removeListener(ossimListener *listener)
Overrides base "removeListener".
virtual bool execute()
Calls: writeFile() writeMetaDataFiles()

◆ printOutputTypes()

void printOutputTypes ( )

Definition at line 137 of file image_copy.cpp.

References ossimImageWriterFactoryRegistry::getImageTypeList(), and ossimImageWriterFactoryRegistry::instance().

Referenced by usage().

138 {
139  std::vector<ossimString> outputType;
140 
142  std::copy(outputType.begin(),
143  outputType.end(),
144  ostream_iterator<ossimString>(cout, "\n"));
145 }
static ossimImageWriterFactoryRegistry * instance()
virtual void getImageTypeList(std::vector< ossimString > &imageTypeList) const
getImageTypeList.

◆ usage()

void usage ( )

Definition at line 130 of file image_copy.cpp.

References printOutputTypes().

Referenced by main().

131 {
132  cout << "image_copy <output_type> <input filename> <output filename>" << endl
133  << "where output types are: " << endl;
135 }
void printOutputTypes()
Definition: image_copy.cpp:137