27 static ossimTrace traceDebug(
"ossimGeneralRasterWriter:debug");
30 "ossimGeneralRasterWriter",
33 static const char DEFAULT_FILE_NAME[] =
"output.ras";
39 theOwnsStreamFlag(false),
156 static const char MODULE[] =
"ossimGeneralRasterWriter::writeStream";
184 << MODULE <<
" ERROR:" 210 static const char*
const MODULE =
"ossimGeneralRasterWriter::writeToBip";
212 if (traceDebug())
CLOG <<
" Entered." << std::endl;
235 <<
"\nossimGeneralRasterWriter::writeToBip DEBUG:" 236 <<
"\nbands: " << bands
237 <<
"\ntilesWide: " << tilesWide
238 <<
"\ntilesHigh: " << tilesHigh
239 <<
"\ntileHeight: " << tileHeight
240 <<
"\nnumberOfTiles: " << numberOfTiles
241 <<
"\nwidth: " << width
250 unsigned char* buffer = NULL;
255 bool wroteSomethingOut =
false;
262 memset(buffer, 0, bufferSizeInBytes);
279 bytesInLine =
id->getScalarSizeInBytes() * width * bands;
284 bufferSizeInBytes = bytesInLine * tileHeight;
285 buffer =
new unsigned char[bufferSizeInBytes];
286 memset(buffer, 0, bufferSizeInBytes);
288 id->unloadTile(buffer,
299 bufferRect.
ul().
y + 1));
306 std::streamsize lineBytes = bytesInLine;
307 wroteSomethingOut =
true;
311 endian.
swap(scalarType,
319 << MODULE <<
" ERROR:" 320 <<
"Error returned writing line!" << std::endl;
335 double numTiles = numberOfTiles;
349 if (traceDebug())
CLOG <<
" Exited." << std::endl;
351 return wroteSomethingOut;
357 static const char*
const MODULE =
"ossimGeneralRasterWriter::writeToBil";
359 if (traceDebug())
CLOG <<
" Entered." << std::endl;
377 unsigned char* buffer = NULL;
384 bool wroteSomethingOut =
false;
392 memset(buffer, 0, bufferSizeInBytes);
399 tileHeight + (tileHeight - 1));
412 bytesInLine =
id->getScalarSizeInBytes() * width;
415 bufferSizeInBytes = bytesInLine * tileHeight * bands;
416 buffer =
new unsigned char[bufferSizeInBytes];
417 memset(buffer, 0, bufferSizeInBytes);
419 id->unloadTile(buffer,
430 bufferRect.
ul().
y + 1));
440 wroteSomethingOut =
true;
443 endian.
swap(scalarType,
451 << MODULE <<
" ERROR:" 452 <<
"Error returned writing line!" << std::endl;
468 double numTiles = numberOfTiles;
484 if (traceDebug())
CLOG <<
" Exited." << std::endl;
486 return wroteSomethingOut;
492 static const char*
const MODULE =
"ossimGeneralRasterWriter::writeToBsq";
494 if (traceDebug())
CLOG <<
" Entered." << std::endl;
518 streampos file_band_offset = 0;
524 unsigned char* buffer = NULL;
530 bool wroteSomethingOut =
false;
537 memset(buffer, 0, bufferSizeInBytes);
544 tileHeight + (tileHeight - 1));
556 bytesInLine =
id->getScalarSizeInBytes() * width;
557 buf_band_offset = bytesInLine * tileHeight;
558 file_band_offset = height * bytesInLine;
559 bufferSizeInBytes = bytesInLine * tileHeight * bands;
560 buffer =
new unsigned char[bufferSizeInBytes];
561 memset(buffer, 0, bufferSizeInBytes);
563 id->unloadTile(buffer,
574 bufferRect.
ul().
y + 1));
583 buf += buf_band_offset * band;
586 streampos pos = file_band_offset * band + start_line * bytesInLine;
591 <<
"Error returned seeking to image data position!" << std::endl;
598 wroteSomethingOut =
true;
601 endian.
swap(scalarType,
611 <<
"Error returned writing line!" << std::endl;
622 double numTiles = numberOfTiles;
635 if (traceDebug())
CLOG <<
" Exited." << std::endl;
637 return wroteSomethingOut;
641 const char* prefix)
const 706 static const char MODULE[] =
"ossimGeneralRasterWriter::writeHeader";
708 if (traceDebug())
CLOG <<
" Entered..." << std::endl;
715 os.open(headerFile.
c_str(), ios::out);
719 <<
"Could not open: " << headerFile << std::endl;
727 getOutputScalarType());
729 os <<
"// *** ossim meta data general raster header file ***\n" 735 << interleaveType.
c_str() <<
"\n" 743 << scalar.
c_str() <<
"\n" 750 os <<
"\n// NOTE: Bands are one based, band1 is the first band." 759 getNullPixelValue(i));
766 getMinPixelValue(i));
768 getMaxPixelValue(i));
777 << null_pix.
c_str() <<
"\n" 779 << min_pix.
c_str() <<
"\n" 781 << max_pix.
c_str() << std::endl;
786 if (traceDebug())
CLOG <<
" Exited..." << endl;
791 static const char MODULE[] =
"ossimGeneralRasterWriter::writeEnviHeader";
793 if (traceDebug())
CLOG <<
" Entered..." << endl;
816 if (traceDebug())
CLOG <<
" Exited..." << endl;
827 imageTypeList.push_back(
ossimString(
"general_raster_bip"));
828 imageTypeList.push_back(
ossimString(
"general_raster_bil"));
829 imageTypeList.push_back(
ossimString(
"general_raster_bsq"));
830 imageTypeList.push_back(
ossimString(
"general_raster_bip_envi"));
831 imageTypeList.push_back(
ossimString(
"general_raster_bil_envi"));
832 imageTypeList.push_back(
ossimString(
"general_raster_bsq_envi"));
841 interleaveType =
"bip";
846 interleaveType =
"bil";
851 interleaveType =
"bsq";
853 return interleaveType;
static const char * BYTE_ORDER_KW
static const char * MIN_VALUE_KW
virtual void slaveProcessTiles()
virtual void setOutputImageType(ossim_int32 type)
virtual bool writeStream()
Method to write the image to a stream.
ossimString getInterleaveString() const
ossimString theOutputImageType
bool needsAborting() const
virtual bool isMaster() const
Represents serializable keyword/value map.
virtual void computeMinMaxPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands) const
If the minBands and maxBands are empty or not equal to the imageData's current number of bands it wil...
ossimGeneralRasterWriter()
default constructor
virtual void setToStartOfSequence()
static const ossimErrorCode OSSIM_OK
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
const char * find(const char *key) const
virtual ossimString getEntryString(ossim_int32 entry_number) const
ossim_int64 getNumberOfTiles() const
static const char * MAX_VALUE_KW
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossim_uint32 height() const
ossimByteOrder theOutputByteOrder
bool contains(char aChar) const
static const char * NULL_VALUE_KW
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
ossimIrect theAreaOfInterest
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_LINES_KW
const ossimIpt & ul() const
OSSIM_DLL ossimByteOrder byteOrder()
Pure virtual base class for image file writers.
virtual ~ossimGeneralRasterWriter()
Protected ( this is a ossimRefPtr) destructor.
void writeEnviHeader() const
Writes an envi header file which can be used to load file in envi.
virtual ossimImageSourceSequencer * getSequencer()
bool writeToBil()
Writes image data to output file in BIL(Band Interleaved by Line) format.
std::vector< double > theMaxPerBand
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
RTTI_DEF1(ossimGeneralRasterWriter, "ossimGeneralRasterWriter", ossimImageFileWriter) static const char DEFAULT_FILE_NAME[]
std::string::size_type size() const
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
virtual ossimString getExtension() const
Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for...
ossimFilename theFilename
unsigned long long ossim_uint64
static const char * INPUT_RR_LEVEL_KW
unsigned int ossim_uint32
virtual void getImageTypeList(std::vector< ossimString > &imageTypeList) const
void getImageTypeList(std::vector<ossimString>& imageTypeList)const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
saves the state of the object.
OSSIM_DLL ossim_uint32 scalarSizeInBytes(ossimScalarType scalarType)
const ossimIpt & lr() const
static const char * NUMBER_BANDS_KW
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
ossim_uint32 width() const
static const char * BAND_KW
ossimByteOrder getSystemEndianType() const
bool writeToBsq()
Writes image data to output file in BSQ(Band Sequential) format.
virtual ossimString getOutputImageTypeString() const
virtual bool writeFile()
Write out the file.
virtual bool isOpen() const
virtual void setFilename(const ossimFilename &file)
virtual bool setOutputStream(std::ostream &stream)
Sets the output stream to write to.
static const char * INTERLEAVE_TYPE_KW
ossim_int64 getNumberOfTilesHorizontal() const
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
virtual ossimErrorCode getErrorStatus() const
virtual void setWriteExternalGeometryFlag(bool flag)
virtual void setErrorStatus() const
std::ostream * theOutputStream
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
static const char * SCALAR_TYPE_KW
ossimFilename file() const
bool writeToBip()
Writes image data to output file in BIP(Band Interleaved by Pixel) format.
std::basic_ofstream< char > ofstream
Class for char output file streams.
static const char * IMAGE_TYPE_KW
virtual void setPercentComplete(double percentComplete)
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
std::vector< double > theMinPerBand
Populated while writting the data.
static const char * FILENAME_KW
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
static const char * NUMBER_SAMPLES_KW
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossim_int64 getNumberOfTilesVertical() const
std::basic_ostream< char > ostream
Base class for char output streams.
void writeHeader() const
Writes an ossim header file which can be used to load file in ossim.