OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ossimWriter Class Reference

ossimWriter - Generic image writer. More...

#include <ossimWriter.h>

Inheritance diagram for ossimWriter:
ossimImageFileWriter ossimImageWriter ossimProcessInterface ossimConnectableObjectListener ossimOutputSource ossimListener ossimSource ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Member Functions

 ossimWriter ()
 default constructor More...
 
virtual ~ossimWriter ()
 virtual destructor More...
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getClassName () const
 
virtual ossimString getExtension () const
 Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions. More...
 
virtual void getImageTypeList (std::vector< ossimString > &imageTypeList) const
 getImageTypeList method. More...
 
virtual bool isOpen () const
 isOpen More...
 
virtual bool open ()
 open More...
 
virtual void close ()
 close Flushes and deletes stream if we own it. More...
 
bool hasImageType (const ossimString &imageType) const
 bool hasImageType(const ossimString& imageType) const More...
 
virtual bool writeStream ()
 Method to write the image to a stream. More...
 
virtual bool setOutputStream (std::ostream &str)
 Sets the output stream to write to. More...
 
virtual void setTileSize (const ossimIpt &tileSize)
 Sets the output tile size for tiled formats. More...
 
virtual const ossimIptgetOutputTileSize () const
 Gets the tile size. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves the state of the object. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of an object from a keyword list. More...
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 Will set the property whose name matches the argument "property->getName()". More...
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 Pushes this's names onto the list of property names. More...
 
- Public Member Functions inherited from ossimImageFileWriter
 ossimImageFileWriter (const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
 The writer will own the sequencer. More...
 
virtual ~ossimImageFileWriter ()
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual bool getOutputHasInternalOverviews (void) const
 Examples of writers that always generate internal overviews are ossim_kakadu_jp2 and ossim_kakadu_nitf_j2k. More...
 
virtual bool writeEnviHeaderFile ()
 Will write an envi header file. More...
 
virtual bool writeErsHeaderFile ()
 Will write an ER Mapper header file. More...
 
virtual bool writeExternalGeometryFile ()
 Will write an external geometry file. More...
 
virtual bool writeFgdcFile ()
 Will write an fgdc file. More...
 
virtual bool writeHistogramFile ()
 Returns true on success, false on error. More...
 
virtual bool writeJpegWorldFile ()
 Will write a jpeg world file. More...
 
virtual bool writeOverviewFile (ossim_uint16 tiff_compress_type=1, ossim_int32 jpeg_compress_quality=75, bool includeR0=false)
 Write out an ossim overview file from the source_file. More...
 
virtual bool writeReadmeFile ()
 Will write a readme file. More...
 
virtual bool writeTiffWorldFile ()
 Will write a world file. More...
 
virtual bool writeWorldFile ()
 Will write a world file. More...
 
virtual bool writeMetaDataFiles ()
 Convenience method that calls meta data write methods that are flagged to be called. More...
 
virtual void setAreaOfInterest (const ossimIrect &inputRect)
 
virtual void changeSequencer (ossimImageSourceSequencer *sequencer)
 Sets the sequencer and connects it to the input of this. More...
 
virtual ossimImageSourceSequencergetSequencer ()
 
virtual void initialize ()
 Initialize method. More...
 
virtual bool execute ()
 Calls: writeFile() writeMetaDataFiles() More...
 
virtual bool setOutputStream (ossimRefPtr< ossimOStream > stream)
 Sets the output stream to write to. More...
 
virtual ossimRefPtr< ossimOStreamgetOutputStream () const
 Method to return the stream attached to output. More...
 
virtual void setPercentComplete (double percentComplete)
 
virtual void setOutputImageType (ossim_int32 type)
 
virtual void setOutputImageType (const ossimString &type)
 
virtual ossim_int32 getOutputImageType () const
 
virtual ossimString getOutputImageTypeString () const
 
virtual void setOutputName (const ossimString &outputName)
 
virtual void setFilename (const ossimFilename &file)
 
virtual const ossimFilenamegetFilename () const
 
virtual bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void propertyEvent (ossimPropertyEvent &event)
 
virtual bool getWriteImageFlag () const
 Control flags... More...
 
virtual bool getWriteHistogramFlag () const
 
virtual bool getWriteOverviewFlag () const
 
virtual bool getScaleToEightBitFlag () const
 
virtual bool getWriteEnviHeaderFlag () const
 
virtual bool getWriteErsHeaderFlag () const
 
virtual bool getWriteExternalGeometryFlag () const
 
virtual bool getWriteFgdcFlag () const
 
virtual bool getWriteJpegWorldFileFlag () const
 
virtual bool getWriteReadmeFlag () const
 
virtual bool getWriteTiffWorldFileFlag () const
 
virtual bool getWriteWorldFileFlag () const
 
virtual void setWriteImageFlag (bool flag)
 
virtual void setWriteOverviewFlag (bool flag)
 
virtual void setWriteHistogramFlag (bool flag)
 
virtual void setScaleToEightBitFlag (bool flag)
 
virtual void setWriteEnviHeaderFlag (bool flag)
 
virtual void setWriteErsHeaderFlag (bool flag)
 
virtual void setWriteExternalGeometryFlag (bool flag)
 
virtual void setWriteFgdcFlag (bool flag)
 
virtual void setWriteJpegWorldFile (bool flag)
 
virtual void setWriteReadme (bool flag)
 
virtual void setWriteTiffWorldFile (bool flag)
 
virtual void setWriteWorldFile (bool flag)
 
virtual ossim_uint16 getOverviewCompressType () const
 
virtual ossim_int32 getOverviewJpegCompressQuality () const
 
virtual void setOverviewCompressType (ossim_uint16 type)
 
virtual void setOverviewJpegCompressQuality (ossim_int32 quality)
 
virtual bool addListener (ossimListener *listener)
 Overrides base "addListener" this will capture the pointer and then call the base class "addListener". More...
 
virtual bool removeListener (ossimListener *listener)
 Overrides base "removeListener". More...
 
virtual void setPixelType (ossimPixelType type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual void setPixelType (const ossimString &type)
 If "point" the coordinate tie points are relative to the center of the pixel. More...
 
virtual ossimPixelType getPixelType () const
 
virtual void getPixelTypeString (ossimString &type) const
 
- Public Member Functions inherited from ossimImageWriter
 ossimImageWriter (ossimObject *owner=NULL)
 
 ossimImageWriter (ossimObject *owner, ossim_uint32 numberOfInputs, ossim_uint32 numberOfOutputs, bool inputListIsFixed, bool outputListIsFixed)
 
virtual ~ossimImageWriter ()
 
virtual bool setViewingRect (const ossimIrect &aRect)
 
virtual ossimIrect getAreaOfInterest () const
 
- Public Member Functions inherited from ossimOutputSource
 ossimOutputSource (ossimObject *owner=NULL)
 
 ossimOutputSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimOutputSource ()
 
virtual bool open (const ossimString &outputName)
 
virtual const ossimStringgetOutputName ()
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimProcessInterface
 ossimProcessInterface ()
 
virtual ~ossimProcessInterface ()
 
virtual void abort ()
 
bool needsAborting () const
 
bool isAbortRequested () const
 
bool isAborted () const
 
bool isExecuting () const
 
ossimProcessStatus getProcessStatus () const
 
virtual void setProcessStatus (ossimProcessStatus processStatus)
 
virtual double getPercentComplete () const
 
virtual ossimListenerManagergetManager ()
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
virtual std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &)
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (ossimConnectionEvent &)
 
virtual void addObjectEvent (ossimContainerEvent &)
 
virtual void removeObjectEvent (ossimContainerEvent &)
 
virtual void containerEvent (ossimContainerEvent &)
 
virtual void refreshEvent (ossimRefreshEvent &)
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 

Protected Member Functions

virtual bool writeFile ()
 Write out the file. More...
 
- Protected Member Functions inherited from ossimImageFileWriter
bool writeWorldFile (const ossimFilename &file)
 Common world file writer method. More...
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Private Member Functions

bool writeStreamTtbs ()
 Writes a tiled tiff band separate to stream. More...
 
bool writeTiffHdr ()
 Writes tiff header to stream. More...
 
bool writeTiffTags (const std::vector< ossim_uint64 > &tile_offsets, const std::vector< ossim_uint64 > &tile_byte_counts, const std::vector< ossim_float64 > &minBands, const std::vector< ossim_float64 > &maxBands)
 Writes tags to image file directory(IFD). More...
 
bool writeMinMaxTiffTags (std::streamoff &arrayWritePos)
 Writes tags TIFFTAG_MINSAMPLEVALUE(280) and TIFFTAG_MAXSAMPLEVALUE(281). More...
 
bool writeSMinSMaxTiffTags (const std::vector< ossim_float64 > &minBands, const std::vector< ossim_float64 > &maxBands, std::streamoff &arrayWritePos)
 Writes tags TIFFTAG_SMINSAMPLEVALUE(340) and TIFFTAG_SMAXSAMPLEVALUE(341). More...
 
template<class T >
void writeTiffTag (ossim_uint16 tag, ossim_uint16 type, ossim_uint64 count, const T *value, std::streamoff &arrayWritePos)
 Writes tiff tag to image file directory(IFD). More...
 
bool writeTiffTilesBandSeparate (std::vector< ossim_uint64 > &tile_offsets, std::vector< ossim_uint64 > &tile_byte_counts, std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands)
 Writes image data to stream. More...
 
ossim_uint16 getTiffSampleFormat () const
 Gets the tiff sample format based on scalar type. More...
 
bool isTiled () const
 
bool getAlignTilesFlag () const
 
ossim_int64 getBlockSize () const
 
bool getFlushTilesFlag () const
 
bool getWriteBlanksFlag () const
 
bool needsMinMax () const
 

Private Attributes

std::ostream * m_str
 
bool m_ownsStreamFlag
 
ossimRefPtr< ossimKeywordlistm_kwl
 Hold all options. More...
 
ossimIpt m_outputTileSize
 

Additional Inherited Members

- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 
- Public Types inherited from ossimProcessInterface
enum  ossimProcessStatus {
  PROCESS_STATUS_UNKNOWN = 0, PROCESS_STATUS_EXECUTING = 1, PROCESS_STATUS_ABORTED = 2, PROCESS_STATUS_ABORT_REQUEST = 3,
  PROCESS_STATUS_NOT_EXECUTING = 4
}
 
- Protected Attributes inherited from ossimImageFileWriter
ossimRefPtr< ossimImageSourceSequencertheInputConnection
 
ossimRefPtr< ossimViewControllertheViewController
 
ossimListenertheProgressListener
 
ossimFilename theFilename
 
ossimString theOutputImageType
 
bool theWriteImageFlag
 
bool theWriteOverviewFlag
 
bool theWriteHistogramFlag
 
bool theScaleToEightBitFlag
 
ossim_uint16 theOverviewCompressType
 
ossim_int32 theOverviewJpegCompressQuality
 
bool theWriteEnviHeaderFlag
 External meta data writer flags. More...
 
bool theWriteErsHeaderFlag
 
bool theWriteExternalGeometryFlag
 
bool theWriteFgdcFlag
 
bool theWriteJpegWorldFileFlag
 
bool theWriteReadmeFlag
 
bool theWriteTiffWorldFileFlag
 
bool theWriteWorldFileFlag
 
bool theAutoCreateDirectoryFlag
 
ossimUnitType theLinearUnits
 If not a geographic projection this allows the user to set the linear units of the output tag to be: More...
 
ossimPixelType thePixelType
 OSSIM_PIXEL_IS_POINT = 0, OSSIM_PIXEL_IS_AREA = 1. More...
 
- Protected Attributes inherited from ossimImageWriter
ossimIrect theAreaOfInterest
 
- Protected Attributes inherited from ossimOutputSource
ossimString theOutputName
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 
- Protected Attributes inherited from ossimProcessInterface
double thePercentComplete
 
ossimProcessStatus theProcessStatus
 
ossimString theMessage
 
bool theEventFlag
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

ossimWriter - Generic image writer.

Please do NOT add any external library dependencies. drb - 26 May 2016

Definition at line 28 of file ossimWriter.h.

Constructor & Destructor Documentation

◆ ossimWriter()

ossimWriter::ossimWriter ( )

default constructor

Definition at line 37 of file ossimWriter.cpp.

References ossimKeywordlist::addPair(), ossim::defaultTileSize(), m_kwl, and m_outputTileSize.

39  m_str(0),
40  m_ownsStreamFlag(false),
41  m_kwl(new ossimKeywordlist()),
43 {
44  // Set default options:
46 
47  m_kwl->addPair( ALIGN_TILES_KW, TRUE_KW );
48  m_kwl->addPair( BLOCK_SIZE_KW, "4096" );
49  m_kwl->addPair( FLUSH_TILES_KW, TRUE_KW );
50  m_kwl->addPair( INCLUDE_BLANK_TILES_KW, TRUE_KW );
51  m_kwl->addPair( TILE_SIZE_KW, m_outputTileSize.toString().string() );
52 }
ossimString toString() const
Definition: ossimIpt.cpp:139
Represents serializable keyword/value map.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
std::ostream * m_str
Definition: ossimWriter.h:289
ossimImageFileWriter(const ossimFilename &filename=ossimFilename(), ossimImageSource *inputSource=0, ossimObject *owner=0)
The writer will own the sequencer.
#define OSSIM_DEFAULT_TILE_WIDTH
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
#define OSSIM_DEFAULT_TILE_HEIGHT
bool m_ownsStreamFlag
Definition: ossimWriter.h:290
const std::string & string() const
Definition: ossimString.h:414

◆ ~ossimWriter()

ossimWriter::~ossimWriter ( )
virtual

virtual destructor

Definition at line 54 of file ossimWriter.cpp.

References close(), and m_kwl.

55 {
56  close();
57 
58  // Not a leak, ref ptr.
59  m_kwl = 0;
60 }
virtual void close()
close Flushes and deletes stream if we own it.
Definition: ossimWriter.cpp:62
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293

Member Function Documentation

◆ close()

void ossimWriter::close ( )
virtual

close Flushes and deletes stream if we own it.

Implements ossimOutputSource.

Definition at line 62 of file ossimWriter.cpp.

References m_ownsStreamFlag, and m_str.

Referenced by open(), writeFile(), and ~ossimWriter().

63 {
64  if (m_str)
65  {
66  m_str->flush();
67 
68  if (m_ownsStreamFlag)
69  {
70  delete m_str;
71  m_str = 0;
72  m_ownsStreamFlag = false;
73  }
74  }
75 }
std::ostream * m_str
Definition: ossimWriter.h:289
bool m_ownsStreamFlag
Definition: ossimWriter.h:290

◆ getAlignTilesFlag()

bool ossimWriter::getAlignTilesFlag ( ) const
private
Returns
Value of options key: "align_tiles". If true, aligns tile addresses to 4096 boundary. default=true

Definition at line 1219 of file ossimWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1220 {
1221  bool result = true; // default
1222  std::string value = m_kwl->findKey( ALIGN_TILES_KW );
1223  if ( value.size() )
1224  {
1225  result = ossimString(value).toBool();
1226  }
1227  return result;
1228 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
bool toBool() const
String to numeric methods.

◆ getBlockSize()

ossim_int64 ossimWriter::getBlockSize ( ) const
private
Returns
Value of options key: "flush_tiles". If true, aligns tile addresses to block boundary. default=true

Definition at line 1230 of file ossimWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1231 {
1232  ossim_int64 result = 4096; // default
1233  std::string value = m_kwl->findKey( BLOCK_SIZE_KW );
1234  if ( value.size() )
1235  {
1236  result = ossimString(value).toInt64();
1237 
1238  // Disallow anything not on 1024 boundary.
1239  if ( result % 1024 )
1240  {
1241  result = 4096;
1243  << "ossimWriter::getBlockSize ERROR:"
1244  << "\nBlock size MUST be a multiple of 1024!"
1245  << "\nBlock size remains: " << result
1246  << std::endl;
1247  }
1248  }
1249  return result;
1250 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
long long ossim_int64
ossim_int64 toInt64() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getClassName()

ossimString ossimWriter::getClassName ( ) const
virtual
Returns
"ossimWriter"

Reimplemented from ossimObject.

Definition at line 87 of file ossimWriter.cpp.

88 {
89  return ossimString("ossimWriter");
90 }

◆ getExtension()

ossimString ossimWriter::getExtension ( ) const
virtual

Returns a 3-letter extension from the image type descriptor (theOutputImageType) that can be used for image file extensions.

Parameters
imageTypestring representing image type.
Returns
the 3-letter string extension.

Reimplemented from ossimImageFileWriter.

Definition at line 92 of file ossimWriter.cpp.

References ossimImageFileWriter::theOutputImageType.

93 {
94  ossimString result = "";
95  if ( theOutputImageType == "ossim_ttbs" ) // tiled tiff band separate
96  {
97  result = "tif";
98  }
99  return result;
100 }

◆ getFlushTilesFlag()

bool ossimWriter::getFlushTilesFlag ( ) const
private
Returns
Value of options key: "flush_tiles". If true, ostream::flush() is called after each tile write. default=true

Definition at line 1252 of file ossimWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1253 {
1254  bool result = true; // default
1255  std::string value = m_kwl->findKey( FLUSH_TILES_KW );
1256  if ( value.size() )
1257  {
1258  result = ossimString(value).toBool();
1259  }
1260  return result;
1261 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
bool toBool() const
String to numeric methods.

◆ getImageTypeList()

void ossimWriter::getImageTypeList ( std::vector< ossimString > &  imageTypeList) const
virtual

getImageTypeList method.

Satisfies ossimImageFileWriter::getImageTypeList pure virtual.

Appends the writers image types to the "imageTypeList".

Current write type: ossim_ttbs - tiled tiff band separate, big tiff format.

Parameters
imageTypeListlist to append to.

Implements ossimImageFileWriter.

Definition at line 102 of file ossimWriter.cpp.

103 {
104  // imageTypeList.push_back(ossimString("tiff_tiled_band_separate"));
105  imageTypeList.push_back(ossimString("ossim_ttbs")); // tmp drb
106 }

◆ getLongName()

ossimString ossimWriter::getLongName ( ) const
virtual
Returns
"ossim writer"

Reimplemented from ossimObject.

Definition at line 82 of file ossimWriter.cpp.

83 {
84  return ossimString("ossim writer");
85 }

◆ getOutputTileSize()

const ossimIpt & ossimWriter::getOutputTileSize ( ) const
virtual

Gets the tile size.

Returns
Reference to tile size.

Definition at line 1008 of file ossimWriter.cpp.

References m_outputTileSize.

1009 {
1010  return m_outputTileSize;
1011 }
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295

◆ getProperty()

ossimRefPtr< ossimProperty > ossimWriter::getProperty ( const ossimString name) const
virtual
Parameters
nameName of property to return.
Returns
A pointer to a property object which matches "name". Returns NULL if no match is found.

Reimplemented from ossimImageFileWriter.

Definition at line 1113 of file ossimWriter.cpp.

References ossimString::string().

1114 {
1115  ossimRefPtr<ossimProperty> prop = 0;
1116 
1117  if ( name.string() == ALIGN_TILES_KW )
1118  {
1119  std::string value = m_kwl->findKey( ALIGN_TILES_KW );
1121  new ossimBooleanProperty(name, ossimString(value).toBool());
1122  prop = boolProp.get();
1123  }
1124  else if( name == BLOCK_SIZE_KW )
1125  {
1126  // Property a single int, e.g.: 4096
1127  ossim_int64 blockSize = getBlockSize();
1129  new ossimStringProperty(name, ossimString::toString(blockSize), false); // editable flag
1130  prop = stringProp.get();
1131  }
1132  else if ( name.string() == FLUSH_TILES_KW )
1133  {
1134  std::string value = m_kwl->findKey( FLUSH_TILES_KW );
1136  new ossimBooleanProperty(name, ossimString(value).toBool());
1137  prop = boolProp.get();
1138  }
1139  else if ( name.string() == INCLUDE_BLANK_TILES_KW )
1140  {
1141  std::string value = m_kwl->findKey( INCLUDE_BLANK_TILES_KW );
1143  new ossimBooleanProperty(name, ossimString(value).toBool());
1144  prop = boolProp.get();
1145  }
1146  else if( name == TILE_SIZE_KW )
1147  {
1148  // Property a single int, e.g.: 256
1150  new ossimStringProperty(name, ossimString::toString(m_outputTileSize.x), false); // editable flag
1151  stringProp->setReadOnlyFlag(false);
1153  stringProp->addConstraint(ossimString("16"));
1154  stringProp->addConstraint(ossimString("32"));
1155  stringProp->addConstraint(ossimString("64"));
1156  stringProp->addConstraint(ossimString("128"));
1157  stringProp->addConstraint(ossimString("256"));
1158  stringProp->addConstraint(ossimString("512"));
1159  stringProp->addConstraint(ossimString("1024"));
1160  stringProp->addConstraint(ossimString("2048"));
1161  prop = stringProp.get();
1162  }
1163  else
1164  {
1165  prop = ossimImageFileWriter::getProperty(name);
1166  }
1167  return prop;
1168 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
static ossimString toString(bool aValue)
Numeric to string methods.
void setChangeType(int type, bool on=true)
virtual void setReadOnlyFlag(bool flag)
void addConstraint(const ossimString &value)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
ossim_int64 getBlockSize() const
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
long long ossim_int64
ossim_int32 x
Definition: ossimIpt.h:141
const std::string & string() const
Definition: ossimString.h:414

◆ getPropertyNames()

void ossimWriter::getPropertyNames ( std::vector< ossimString > &  propertyNames) const
virtual

Pushes this's names onto the list of property names.

Parameters
propertyNamesarray to add this's property names to.

Reimplemented from ossimImageFileWriter.

Definition at line 1170 of file ossimWriter.cpp.

1171 {
1172  propertyNames.push_back(ossimString(ALIGN_TILES_KW));
1173  propertyNames.push_back(ossimString(BLOCK_SIZE_KW));
1174  propertyNames.push_back(ossimString(FLUSH_TILES_KW));
1175  propertyNames.push_back(ossimString(INCLUDE_BLANK_TILES_KW));
1176  propertyNames.push_back(ossimString(TILE_SIZE_KW));
1178 }
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const

◆ getShortName()

ossimString ossimWriter::getShortName ( ) const
virtual
Returns
"ossim_writer"

Reimplemented from ossimObject.

Definition at line 77 of file ossimWriter.cpp.

78 {
79  return ossimString("ossim_writer");
80 }

◆ getTiffSampleFormat()

ossim_uint16 ossimWriter::getTiffSampleFormat ( ) const
private

Gets the tiff sample format based on scalar type.

E.g SAMPLEFORMAT_UINT, SAMPLEFORMAT_INT or SAMPLEFORMAT_IEEEFP.

Returns
TIFF sample format or 0 if not mapped to a scalar type.

Definition at line 1180 of file ossimWriter.cpp.

References ossimImageSourceSequencer::getOutputScalarType(), ossim::OSAMPLEFORMAT_IEEEFP, ossim::OSAMPLEFORMAT_INT, ossim::OSAMPLEFORMAT_UINT, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, and ossimImageFileWriter::theInputConnection.

Referenced by writeTiffTags().

1181 {
1182  ossim_uint16 result = 0;
1184  {
1185  case OSSIM_UINT8:
1186  case OSSIM_USHORT11:
1187  case OSSIM_USHORT12:
1188  case OSSIM_USHORT13:
1189  case OSSIM_USHORT14:
1190  case OSSIM_USHORT15:
1191  case OSSIM_UINT16:
1192  case OSSIM_UINT32:
1193  result = ossim::OSAMPLEFORMAT_UINT;
1194  break;
1195 
1196  case OSSIM_SINT16:
1197  result = ossim::OSAMPLEFORMAT_INT;
1198  break;
1199 
1200  case OSSIM_FLOAT32:
1201  case OSSIM_FLOAT64:
1204  result = ossim::OSAMPLEFORMAT_IEEEFP;
1205  break;
1206 
1207  default:
1208  break;
1209  }
1210 
1211  return result;
1212 }
16 bit unsigned integer (15 bits used)
64 bit floating point
16 bit unsigned integer
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
unsigned short ossim_uint16
32 bit unsigned integer
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
32 bit normalized floating point
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
8 bit unsigned integer
16 bit unsigned integer (12 bits used)

◆ getWriteBlanksFlag()

bool ossimWriter::getWriteBlanksFlag ( ) const
private
Returns
Value of options key: "include_blank_tiles". If true, empty/blank tiles will be written; if false, the tile will not be written, the tile offset and byte count will be set to zero. default=true (write blanks).

Definition at line 1263 of file ossimWriter.cpp.

References ossimKeywordlist::findKey(), and m_kwl.

1264 {
1265  bool result = true; // default
1266  std::string value = m_kwl->findKey( INCLUDE_BLANK_TILES_KW );
1267  if ( value.size() )
1268  {
1269  result = ossimString(value).toBool();
1270  }
1271  return result;
1272 }
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
bool toBool() const
String to numeric methods.

◆ hasImageType()

bool ossimWriter::hasImageType ( const ossimString imageType) const
virtual

bool hasImageType(const ossimString& imageType) const

Parameters
imageTypestring representing image type.
Returns
true if "imageType" is supported by writer.

Reimplemented from ossimImageFileWriter.

Definition at line 139 of file ossimWriter.cpp.

Referenced by open().

140 {
141  bool result = false;
142  if ( (imageType == "ossim_ttbs") || (imageType == "image/tif") )
143  {
144  result = true;
145  }
146  return result;
147 }

◆ isOpen()

bool ossimWriter::isOpen ( ) const
virtual

isOpen

Returns
true if open; else, false.

Implements ossimOutputSource.

Definition at line 108 of file ossimWriter.cpp.

References m_str.

Referenced by writeFile(), and writeStream().

109 {
110  return ( m_str ? true : false );
111 }
std::ostream * m_str
Definition: ossimWriter.h:289

◆ isTiled()

bool ossimWriter::isTiled ( ) const
private
Returns
true if the output type is tiled, false if not.

Definition at line 1214 of file ossimWriter.cpp.

References ossimImageFileWriter::theOutputImageType.

Referenced by writeTiffTags().

1215 {
1216  return ( theOutputImageType == "ossim_ttbs" );
1217 }

◆ loadState()

bool ossimWriter::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of an object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimImageFileWriter.

Definition at line 1020 of file ossimWriter.cpp.

References ossimKeywordlist::findKey(), ossimImageFileWriter::loadState(), and ossimImageFileWriter::theOutputImageType.

1021 {
1022  bool result = false;
1023  if ( ossimImageFileWriter::loadState(kwl, prefix) )
1024  {
1025  if ( theOutputImageType!="ossim_ttbs")
1026  {
1027  result = true;
1028 
1029  std::string pfx = prefix?prefix:"";
1030  std::string value;
1031 
1032  value = kwl.findKey( pfx, ALIGN_TILES_KW );
1033  if ( value.size() )
1034  {
1035  m_kwl->addPair( ALIGN_TILES_KW, value, true );
1036  }
1037 
1038  value = kwl.findKey( pfx, BLOCK_SIZE_KW );
1039  if ( value.size() )
1040  {
1041  m_kwl->addPair( BLOCK_SIZE_KW, value, true );
1042  }
1043 
1044  value = kwl.findKey( pfx, FLUSH_TILES_KW );
1045  if ( value.size() )
1046  {
1047  m_kwl->addPair( FLUSH_TILES_KW, value, true );
1048  }
1049 
1050  value = kwl.findKey( pfx, INCLUDE_BLANK_TILES_KW );
1051  if ( value.size() )
1052  {
1053  m_kwl->addPair( INCLUDE_BLANK_TILES_KW, value, true );
1054  }
1055 
1056  value = kwl.findKey( pfx, TILE_SIZE_KW );
1057  if ( value.size() )
1058  {
1059  m_outputTileSize.toPoint(value);
1060  m_kwl->addPair( TILE_SIZE_KW, m_outputTileSize.toString().string(), true );
1061  }
1062  }
1063  }
1064 
1065  return result;
1066 }
ossimString toString() const
Definition: ossimIpt.cpp:139
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimIpt.cpp:170
const std::string & string() const
Definition: ossimString.h:414

◆ needsMinMax()

bool ossimWriter::needsMinMax ( ) const
private

Definition at line 1274 of file ossimWriter.cpp.

References ossimImageSourceSequencer::getOutputScalarType(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_UINT32, and ossimImageFileWriter::theInputConnection.

1275 {
1276  bool result = false;
1278  {
1279  case OSSIM_SINT16:
1280  case OSSIM_UINT32:
1281  case OSSIM_FLOAT32:
1282  case OSSIM_FLOAT64:
1285  {
1286  result = true;
1287  break;
1288  }
1289  default:
1290  {
1291  break;
1292  }
1293  }
1294  return result;
1295 }
64 bit floating point
16 bit signed integer
32 bit floating point
32 bit unsigned integer
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
32 bit normalized floating point
64 bit normalized floating point

◆ open()

bool ossimWriter::open ( )
virtual

open

Returns
true on success, false on error.

Implements ossimOutputSource.

Definition at line 113 of file ossimWriter.cpp.

References ossimString::c_str(), close(), hasImageType(), m_ownsStreamFlag, m_str, ossimString::size(), status, ossimImageFileWriter::theFilename, and ossimImageFileWriter::theOutputImageType.

Referenced by writeFile().

114 {
115  bool status = false;
116 
117  close();
118 
120  {
121  std::ofstream* os = new std::ofstream();
122  os->open( theFilename.c_str(), ios::out | ios::binary );
123  if( os->is_open() )
124  {
125  m_str = os;
126  m_ownsStreamFlag = true;
127  status = true;
128  }
129  else
130  {
131  delete os;
132  os = 0;
133  }
134  }
135 
136  return status;
137 }
bool hasImageType(const ossimString &imageType) const
bool hasImageType(const ossimString& imageType) const
virtual void close()
close Flushes and deletes stream if we own it.
Definition: ossimWriter.cpp:62
std::ostream * m_str
Definition: ossimWriter.h:289
std::string::size_type size() const
Definition: ossimString.h:405
return status
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool m_ownsStreamFlag
Definition: ossimWriter.h:290
std::basic_ofstream< char > ofstream
Class for char output file streams.
Definition: ossimIosFwd.h:47

◆ saveState()

bool ossimWriter::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Saves the state of the object.

Reimplemented from ossimImageFileWriter.

Definition at line 1013 of file ossimWriter.cpp.

References ossimKeywordlist::add(), ossimRefPtr< T >::get(), m_kwl, and ossimImageFileWriter::saveState().

1014 {
1015  // Lazy man save state...
1016  kwl.add( prefix, *(m_kwl.get()), true );
1017  return ossimImageFileWriter::saveState(kwl, prefix);
1018 }
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293

◆ setOutputStream()

bool ossimWriter::setOutputStream ( std::ostream &  str)
virtual

Sets the output stream to write to.

This sets the stream and sets m_ownsStreamFlag to false. So destructor will not delete the stream if this method is used.

Parameters
streamThe stream to write to.
Returns
true if object can write to stream, false if not.

Reimplemented from ossimImageFileWriter.

Definition at line 975 of file ossimWriter.cpp.

References m_ownsStreamFlag, and m_str.

976 {
977  if (m_ownsStreamFlag && m_str)
978  {
979  delete m_str;
980  }
981  m_str = &stream;
982  m_ownsStreamFlag = false;
983  return true;
984 }
std::ostream * m_str
Definition: ossimWriter.h:289
bool m_ownsStreamFlag
Definition: ossimWriter.h:290

◆ setProperty()

void ossimWriter::setProperty ( ossimRefPtr< ossimProperty property)
virtual

Will set the property whose name matches the argument "property->getName()".

Parameters
propertyObject containing property to set.

Reimplemented from ossimImageFileWriter.

Definition at line 1068 of file ossimWriter.cpp.

References ossimRefPtr< T >::valid().

1069 {
1070  if( property.valid() )
1071  {
1072  // See if it's one of our properties:
1073  std::string key = property->getName().string();
1074 
1075  if ( traceDebug() )
1076  {
1077  ossimString value;
1078  property->valueToString(value);
1079 
1081  << "ossimWriter::setProperty DEBUG:"
1082  << "\nkey: " << key
1083  << "\nvalue: " << value << "\n";
1084  }
1085 
1086  if ( ( key == ALIGN_TILES_KW ) ||
1087  ( key == BLOCK_SIZE_KW ) ||
1088  ( key == FLUSH_TILES_KW ) ||
1089  ( key == INCLUDE_BLANK_TILES_KW ) )
1090  {
1091  ossimString value;
1092  property->valueToString(value);
1093  m_kwl->addPair( key, value.string(), true );
1094  }
1095  else if ( key == TILE_SIZE_KW )
1096  {
1097  // Comes in as a single int, e.g.: 256
1098  ossimString value;
1099  property->valueToString(value);
1100  m_outputTileSize.x = value.toInt32();
1102 
1103  // Store in keywordlist / save state as a point, e.g.: ( 256, 256 )
1105  }
1106  else
1107  {
1109  }
1110  }
1111 }
ossimString toString() const
Definition: ossimIpt.cpp:139
bool valid() const
Definition: ossimRefPtr.h:75
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossim_int32 toInt32() const
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
virtual void setProperty(ossimRefPtr< ossimProperty > property)
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ setTileSize()

void ossimWriter::setTileSize ( const ossimIpt tileSize)
virtual

Sets the output tile size for tiled formats.

Parameters
tileSizeMust be a multiple of 16.

Reimplemented from ossimImageFileWriter.

Definition at line 986 of file ossimWriter.cpp.

References ossimIpt::x, and ossimIpt::y.

987 {
988  if ( (tileSize.x % 16) || (tileSize.y % 16) )
989  {
990  if(traceDebug())
991  {
993  << "ossimWriter::setTileSize ERROR:"
994  << "\nTile size must be a multiple of 16!"
995  << "\nSize remains: " << m_outputTileSize
996  << std::endl;
997  }
998  }
999  else
1000  {
1001  m_outputTileSize = tileSize;
1002 
1003  // For save state:
1004  m_kwl->addPair( TILE_SIZE_KW, m_outputTileSize.toString().string() );
1005  }
1006 }
ossimString toString() const
Definition: ossimIpt.cpp:139
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
ossimRefPtr< ossimKeywordlist > m_kwl
Hold all options.
Definition: ossimWriter.h:293
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ writeFile()

bool ossimWriter::writeFile ( )
protectedvirtual

Write out the file.

Returns
true on success, false on error.

Implements ossimImageFileWriter.

Definition at line 149 of file ossimWriter.cpp.

References close(), ossimErrorStatusInterface::getErrorStatus(), ossimImageSourceSequencer::isMaster(), isOpen(), open(), ossimErrorCodes::OSSIM_OK, status, ossimImageFileWriter::theInputConnection, ossimRefPtr< T >::valid(), and writeStream().

150 {
151  bool status = true;
152 
153  if( theInputConnection.valid() &&
155  {
156  //---
157  // Check for stream if master process.
158  // Note only the master process is used for writing...
159  //---
161  {
162  if (!isOpen())
163  {
164  status = open();
165  }
166  }
167 
168  if ( status )
169  {
170  status = writeStream();
171 
172  // Flush and close the stream.
173  close();
174  }
175  }
176 
177  return status;
178 }
virtual void close()
close Flushes and deletes stream if we own it.
Definition: ossimWriter.cpp:62
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
return status
virtual ossimErrorCode getErrorStatus() const
virtual bool writeStream()
Method to write the image to a stream.
virtual bool isOpen() const
isOpen
virtual bool open()
open

◆ writeMinMaxTiffTags()

bool ossimWriter::writeMinMaxTiffTags ( std::streamoff &  arrayWritePos)
private

Writes tags TIFFTAG_MINSAMPLEVALUE(280) and TIFFTAG_MAXSAMPLEVALUE(281).

Only written if scalar type is an unsigned byte or short.

Returns
true on success, false on error.

Definition at line 632 of file ossimWriter.cpp.

References ossimImageSourceSequencer::getOutputScalarType(), OSSIM_UINT16, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossim::OTIFF_SHORT, ossim::OTIFFTAG_MAXSAMPLEVALUE, ossim::OTIFFTAG_MINSAMPLEVALUE, status, and ossimImageFileWriter::theInputConnection.

Referenced by writeTiffTags().

633 {
634  bool status = true;
635 
636  // DEFAULT for OSSIM_UINT32.
637  ossim_uint16 minValue = 1;
638  ossim_uint16 maxValue = 255;
639 
641  {
642  case OSSIM_UINT8:
643  {
644  break; // defaulted above
645  }
646  case OSSIM_USHORT11:
647  {
648  maxValue = 2047;
649  break;
650  }
651  case OSSIM_USHORT12:
652  {
653  maxValue = 4095;
654  break;
655  }
656  case OSSIM_USHORT13:
657  {
658  maxValue = 8191;
659  break;
660  }
661  case OSSIM_USHORT14:
662  {
663  maxValue = 16383;
664  break;
665  }
666  case OSSIM_USHORT15:
667  {
668  maxValue = 32767;
669  break;
670  }
671  case OSSIM_UINT16:
672  {
673  maxValue = 65535;
674  break;
675  }
676  default:
677  status = false;
678  }
679 
680  if ( status )
681  {
682  writeTiffTag<ossim_uint16>( ossim::OTIFFTAG_MINSAMPLEVALUE,
684  1, &minValue, arrayWritePos );
685  writeTiffTag<ossim_uint16>( ossim::OTIFFTAG_MAXSAMPLEVALUE,
687  1, &maxValue, arrayWritePos );
688  }
689 
690  return status;
691 }
16 bit unsigned integer (15 bits used)
16 bit unsigned integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
return status
16 bit unsigned integer (11 bits used)
8 bit unsigned integer
16 bit unsigned integer (12 bits used)

◆ writeSMinSMaxTiffTags()

bool ossimWriter::writeSMinSMaxTiffTags ( const std::vector< ossim_float64 > &  minBands,
const std::vector< ossim_float64 > &  maxBands,
std::streamoff &  arrayWritePos 
)
private

Writes tags TIFFTAG_SMINSAMPLEVALUE(340) and TIFFTAG_SMAXSAMPLEVALUE(341).

Only written if scalar type is not an unsigned byte or short.

Parameters
minBandsArray of min values from image write.
maxBandsArray of max values from image write.
Returns
true if tags are written, false if not. A false return is not necessarily an error, just means the tags were not written due to the scalar type.

Definition at line 693 of file ossimWriter.cpp.

References ossimImageSourceSequencer::getOutputScalarType(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_UINT32, ossim::OTIFF_FLOAT, ossim::OTIFFTAG_SMAXSAMPLEVALUE, ossim::OTIFFTAG_SMINSAMPLEVALUE, status, and ossimImageFileWriter::theInputConnection.

Referenced by writeTiffTags().

696 {
697  bool status = false;
698 
699  if(minBands.size() && maxBands.size())
700  {
701  ossim_float64 minValue = *std::min_element(minBands.begin(), minBands.end());
702  ossim_float64 maxValue = *std::max_element(maxBands.begin(), maxBands.end());
703 
705  {
706  case OSSIM_SINT16:
707  case OSSIM_UINT32:
708  case OSSIM_FLOAT32:
709  case OSSIM_FLOAT64:
712  {
713  ossim_float32 v = static_cast<ossim_float32>(minValue);
714  writeTiffTag<ossim_float32>( ossim::OTIFFTAG_SMINSAMPLEVALUE,
716  1, &v, arrayWritePos );
717  v = static_cast<ossim_float32>(maxValue);
718  writeTiffTag<ossim_float32>( ossim::OTIFFTAG_SMAXSAMPLEVALUE,
720  1, &v, arrayWritePos );
721  status = true;
722  break;
723  }
724  default:
725  {
726  break;
727  }
728  }
729  }
730  return status;
731 }
64 bit floating point
float ossim_float32
16 bit signed integer
32 bit floating point
32 bit unsigned integer
double ossim_float64
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
32 bit normalized floating point
return status
64 bit normalized floating point

◆ writeStream()

bool ossimWriter::writeStream ( )
virtual

Method to write the image to a stream.

Returns
true on success, false on error.

Reimplemented from ossimImageFileWriter.

Definition at line 180 of file ossimWriter.cpp.

References ossimImageSourceSequencer::getTileHeight(), ossimImageSourceSequencer::getTileWidth(), isOpen(), m_outputTileSize, ossimImageSourceSequencer::setTileSize(), status, ossimImageFileWriter::theInputConnection, ossimImageFileWriter::theOutputImageType, ossimRefPtr< T >::valid(), writeStreamTtbs(), ossimIpt::x, and ossimIpt::y.

Referenced by writeFile().

181 {
182  //---
183  // This can be called publically so we must to the same checks as the
184  // writeFile method.
185  //---
186  bool status = false;
187 
188  // Must have a sequencer...
189  if( theInputConnection.valid() )
190  {
191  if ( isOpen() )
192  {
193  if ( theOutputImageType == "ossim_ttbs" )
194  {
195  if ( (theInputConnection->getTileWidth() !=
196  static_cast<ossim_uint32>(m_outputTileSize.x)) ||
198  static_cast<ossim_uint32>(m_outputTileSize.y)) )
199  {
201  }
202 
204  }
205  }
206  }
207 
208  return status;
209 }
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned int ossim_uint32
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
return status
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
virtual bool isOpen() const
isOpen
virtual void setTileSize(const ossimIpt &tileSize)
bool writeStreamTtbs()
Writes a tiled tiff band separate to stream.

◆ writeStreamTtbs()

bool ossimWriter::writeStreamTtbs ( )
private

Writes a tiled tiff band separate to stream.

Returns
true on success, false on error.

Definition at line 211 of file ossimWriter.cpp.

References status, writeTiffHdr(), writeTiffTags(), and writeTiffTilesBandSeparate().

Referenced by writeStream().

212 {
213  // Alway big tiff in native byte order.
214 
215  bool status = false;
216 
217  if ( writeTiffHdr() == true )
218  {
219  std::vector<ossim_uint64> tile_offsets;
220  std::vector<ossim_uint64> tile_byte_counts;
221 
222  //---
223  // Min/max arrays must start off empty for
224  // ossimImageData::computeMinMaxPix code.
225  //---
226  std::vector<ossim_float64> minBands(0);
227  std::vector<ossim_float64> maxBands(0);
228 
230  tile_offsets, tile_byte_counts, minBands, maxBands ) == true )
231  {
232  status = writeTiffTags( tile_offsets, tile_byte_counts, minBands, maxBands );
233  }
234  }
235 
236  return status;
237 }
bool writeTiffHdr()
Writes tiff header to stream.
bool writeTiffTags(const std::vector< ossim_uint64 > &tile_offsets, const std::vector< ossim_uint64 > &tile_byte_counts, const std::vector< ossim_float64 > &minBands, const std::vector< ossim_float64 > &maxBands)
Writes tags to image file directory(IFD).
bool writeTiffTilesBandSeparate(std::vector< ossim_uint64 > &tile_offsets, std::vector< ossim_uint64 > &tile_byte_counts, std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands)
Writes image data to stream.
return status

◆ writeTiffHdr()

bool ossimWriter::writeTiffHdr ( )
private

Writes tiff header to stream.

Returns
true on success, false on error.

Definition at line 239 of file ossimWriter.cpp.

References ossim::byteOrder(), m_str, and OSSIM_LITTLE_ENDIAN.

Referenced by writeStreamTtbs().

240 {
241  //---
242  // First two bytes, byte order indication.
243  // "MM"(big endian) or "II"(little endian.
244  //---
245  std::string s;
247  {
248  s = "II";
249  }
250  else
251  {
252  s = "MM";
253  }
254  m_str->write( s.c_str(), 2 );
255 
256  // Version, 42=classic tiff, 43=big tiff.
257  ossim_uint16 us16 = 43;
258  m_str->write( (const char*)&us16, 2 );
259 
260  // Byte size of offsets.
261  us16 = 8;
262  m_str->write( (const char*)&us16, 2 );
263 
264  // Always 0:
265  us16 = 0;
266  m_str->write( (const char*)&us16, 2 );
267 
268  // Offset to the IFD(image file directory).
269  ossim_uint64 ul64 = 16;
270  m_str->write( (const char*)&ul64, 8 );
271 
272  return m_str->good();
273 }
OSSIM_DLL ossimByteOrder byteOrder()
Definition: ossimCommon.cpp:54
unsigned short ossim_uint16
std::ostream * m_str
Definition: ossimWriter.h:289
unsigned long long ossim_uint64

◆ writeTiffTag()

template<class T >
void ossimWriter::writeTiffTag ( ossim_uint16  tag,
ossim_uint16  type,
ossim_uint64  count,
const T *  value,
std::streamoff &  arrayWritePos 
)
private

Writes tiff tag to image file directory(IFD).

Parameters
tag
type
count
value(s)or offset to array.
arrayWritePosPosition to write array to. This will be updated if array is written with new offset.

Definition at line 734 of file ossimWriter.cpp.

References m_str.

737 {
738  m_str->write( (const char*)&tag, 2 );
739  m_str->write( (const char*)&type, 2 );
740  m_str->write( (const char*)&count, 8 );
741 
742  ossim_uint64 bytes = sizeof( T ) * count;
743 
744  if ( bytes <= 8 )
745  {
746  m_str->write( (const char*)value, bytes );
747  if ( bytes < 8 )
748  {
749  // Fill remaining bytes with 0.
750  char c = '\0';
751  m_str->write( (const char*)&c, (8-bytes) );
752  }
753  }
754  else // Greater than 8 bytes, must write at end of file.
755  {
756  // Store the offset to array:
757  m_str->write( (const char*)&arrayWritePos, 8 );
758 
759  // Capture posistion:
760  std::streamoff currentPos = m_str->tellp();
761 
762  // Seek to end:
763  m_str->seekp( arrayWritePos, std::ios_base::beg );
764 
765  // Write:
766  m_str->write( (const char*)value, bytes );
767 
768  // Capture new offset for next array write.
769  arrayWritePos = m_str->tellp();
770 
771  // Seek back:
772  m_str->seekp( currentPos, std::ios_base::beg );
773  }
774 }
std::ostream * m_str
Definition: ossimWriter.h:289
unsigned long long ossim_uint64

◆ writeTiffTags()

bool ossimWriter::writeTiffTags ( const std::vector< ossim_uint64 > &  tile_offsets,
const std::vector< ossim_uint64 > &  tile_byte_counts,
const std::vector< ossim_float64 > &  minBands,
const std::vector< ossim_float64 > &  maxBands 
)
private

Writes tags to image file directory(IFD).

Parameters
tile_offsets
tile_byte_counts
minBands
maxBands
Returns
true on success, false on error.

Definition at line 275 of file ossimWriter.cpp.

References ossimEllipsoid::a(), ossimEllipsoid::b(), ossim::COMPRESSION_NONE, ossimDatum::ellipsoid(), ossimDatum::epsgCode(), ossimRefPtr< T >::get(), ossim::getBitsPerPixel(), ossimMapProjection::getDatum(), ossimMapProjection::getDecimalDegreesPerPixel(), ossimEllipsoid::getEpsgCode(), ossimImageSource::getImageGeometry(), ossimMapProjection::getMetersPerPixel(), ossimImageSource::getNumberOfOutputBands(), ossimImageSourceSequencer::getOutputScalarType(), ossimMapProjection::getPcsCode(), ossimImageGeometry::getProjection(), getTiffSampleFormat(), ossimIrect::height(), ossimMapProjection::isGeographic(), isTiled(), ossimGpt::lat, ossimMapProjection::lineSampleToEastingNorthing(), ossimMapProjection::lineSampleToWorld(), ossimGpt::lon, m_outputTileSize, m_str, ossim::OANGULAR_DEGREE, ossim::OGEO_DOUBLE_PARAMS_TAG, ossim::OGEO_KEY_DIRECTORY_TAG, ossim::OGEOG_ANGULAR_UNITS_GEO_KEY, ossim::OGEOG_ELLIPSOID_GEO_KEY, ossim::OGEOG_GEODETIC_DATUM_GEO_KEY, ossim::OGEOG_SEMI_MAJOR_AXIS, ossim::OGEOG_SEMI_MINOR_AXIS, ossim::OGEOGRAPHIC_TYPE_GEO_KEY, ossim::OGT_MODEL_TYPE_GEO_KEY, ossim::OGT_RASTER_TYPE_GEO_KEY, ossim::OLINEAR_METER, ossim::OMODEL_PIXEL_SCALE_TAG, ossim::OMODEL_TIE_POINT_TAG, ossim::OMODEL_TYPE_GEOGRAPHIC, ossim::OMODEL_TYPE_PROJECTED, ossim::OPHOTO_MINISBLACK, ossim::OPHOTO_RGB, ossim::OPIXEL_IS_POINT, ossim::OPROJ_LINEAR_UNITS_GEO_KEY, ossim::OPROJECTED_CS_TYPE_GEO_KEY, ossim::OPROJECTION_GEO_KEY, OSSIM_DEFAULT_MAX_PIX_UINT16, ossim::OTIFF_DOUBLE, ossim::OTIFF_LONG, ossim::OTIFF_LONG8, ossim::OTIFF_SHORT, ossim::OTIFFTAG_BITSPERSAMPLE, ossim::OTIFFTAG_COMPRESSION, ossim::OTIFFTAG_IMAGELENGTH, ossim::OTIFFTAG_IMAGEWIDTH, ossim::OTIFFTAG_PHOTOMETRIC, ossim::OTIFFTAG_PLANARCONFIG, ossim::OTIFFTAG_PLANARCONFIG_SEPARATE, ossim::OTIFFTAG_SAMPLEFORMAT, ossim::OTIFFTAG_SAMPLESPERPIXEL, ossim::OTIFFTAG_TILEBYTECOUNTS, ossim::OTIFFTAG_TILELENGTH, ossim::OTIFFTAG_TILEOFFSETS, ossim::OTIFFTAG_TILEWIDTH, status, ossimImageWriter::theAreaOfInterest, ossimImageFileWriter::theInputConnection, true, ossimIrect::ul(), ossimRefPtr< T >::valid(), ossimIrect::width(), writeMinMaxTiffTags(), writeSMinSMaxTiffTags(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

Referenced by writeStreamTtbs().

279 {
280  bool status = false;
281 
284  if ( geom.valid() )
285  {
287  mapProj = dynamic_cast<ossimMapProjection*>( proj.get() );
288  }
289 
290  // Seek to the IFD.
291  m_str->seekp( 16, std::ios_base::beg );
292 
293  // tag count, this will be rewritten at the end:
294  ossim_uint64 tagCount = 0;
295  m_str->write( (const char*)&tagCount, 8 );
296 
297  //---
298  // This is where the tile offsets, tile byte counts and arrays bytes are
299  // written. Starting at byte position 512 which gives from
300  // 16 -> 512(496 bytes) to write tags.
301  //---
302  std::streamoff arrayWritePos = 512;
303 
304  // Used throughout:
305  ossim_uint16 tag;
306  ossim_uint16 type;
307  ossim_uint64 count;
308  ossim_uint16 value_ui16;
309  ossim_uint32 value_ui32;
310 
311  // image width tag 256:
313  count = 1;
315  {
316  type = ossim::OTIFF_SHORT;
317  value_ui16 = (ossim_uint16)theAreaOfInterest.width();
318  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
319  }
320  else
321  {
322  type = ossim::OTIFF_LONG;
323  value_ui32 = theAreaOfInterest.width();
324  writeTiffTag<ossim_uint32>( tag, type, count, &value_ui32, arrayWritePos );
325  }
326  ++tagCount;
327 
328  // image length tag 257:
330  count = 1;
332  {
333  type = ossim::OTIFF_SHORT;
334  value_ui16 = (ossim_uint16)theAreaOfInterest.height();
335  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
336  }
337  else
338  {
339  type = ossim::OTIFF_LONG;
340  value_ui32 = theAreaOfInterest.height();
341  writeTiffTag<ossim_uint32>( tag, type, count, &value_ui32, arrayWritePos );
342  }
343  ++tagCount;
344 
345  // bits per sample tag 258:
348  type = ossim::OTIFF_SHORT;
350  if ( count == 1 )
351  {
352  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
353  }
354  else
355  {
356  std::vector<ossim_uint16> v(count, value_ui16);
357  writeTiffTag<ossim_uint16>( tag, type, count, &v.front(), arrayWritePos );
358  }
359  ++tagCount;
360 
361  // compression tag 259:
363  type = ossim::OTIFF_SHORT;
364  count = 1;
365  value_ui16 = ossim::COMPRESSION_NONE; // tmp only uncompressed supported.
366  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
367  ++tagCount;
368 
369  // photo interpretation tag 262:
371  type = ossim::OTIFF_SHORT;
372  count = 1;
374  {
375  value_ui16 = ossim::OPHOTO_RGB;
376  }
377  else
378  {
379  value_ui16 = ossim::OPHOTO_MINISBLACK;
380  }
381  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
382  ++tagCount;
383 
384  // samples per pixel tag 277:
386  type = ossim::OTIFF_SHORT;
387  count = 1;
389  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
390  ++tagCount;
391 
392  // Writes two tags 280 and 281:
393  if ( writeMinMaxTiffTags( arrayWritePos ) == true )
394  {
395  tagCount += 2;
396  }
397 
398  // planar conf tag 284:
400  type = ossim::OTIFF_SHORT;
401  count = 1;
403  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
404  ++tagCount;
405 
406  if ( isTiled() )
407  {
408  // tile width tag 322:
410  count = 1;
412  {
413  type = ossim::OTIFF_SHORT;
414  value_ui16 = (ossim_uint16)m_outputTileSize.x;
415  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
416  }
417  else
418  {
419  type = ossim::OTIFF_LONG;
420  value_ui32 = (ossim_uint32)m_outputTileSize.x;
421  writeTiffTag<ossim_uint32>( tag, type, count, &value_ui32, arrayWritePos );
422  }
423  ++tagCount;
424 
425  // tile length tag 323:
427  count = 1;
429  {
430  type = ossim::OTIFF_SHORT;
431  value_ui16 = (ossim_uint16)m_outputTileSize.y;
432  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
433  }
434  else
435  {
436  type = ossim::OTIFF_LONG;
437  value_ui32 = (ossim_uint32)m_outputTileSize.y;
438  writeTiffTag<ossim_uint32>( tag, type, count, &value_ui32, arrayWritePos );
439  }
440  ++tagCount;
441  }
442 
443  // tile offsets tag 324:
445  count = tile_offsets.size();
446  type = ossim::OTIFF_LONG8;
447  writeTiffTag<ossim_uint64>( tag, type, count, &tile_offsets.front(), arrayWritePos );
448  ++tagCount;
449 
450  // tile byte counts tag 325:
452  count = tile_byte_counts.size();
453  type = ossim::OTIFF_LONG8;
454  writeTiffTag<ossim_uint64>( tag, type, count, &tile_byte_counts.front(), arrayWritePos );
455  ++tagCount;
456 
457  // sample format tag 339:
460  type = ossim::OTIFF_SHORT;
461  value_ui16 = getTiffSampleFormat();
462  if ( count == 1 )
463  {
464  writeTiffTag<ossim_uint16>( tag, type, count, &value_ui16, arrayWritePos );
465  }
466  else
467  {
468  std::vector<ossim_uint16> v(count, value_ui16);
469  writeTiffTag<ossim_uint16>( tag, type, count, &v.front(), arrayWritePos );
470  }
471  ++tagCount;
472 
473  // Writes two tags 340 and 341 (conditional on scalar type):
474  if ( writeSMinSMaxTiffTags( minBands, maxBands, arrayWritePos ) == true )
475  {
476  tagCount += 2;
477  }
478 
479  // Write geo keys if valid map projection:
480  if ( mapProj.valid() )
481  {
482  std::vector<ossim_float64> vf;
483  ossimDpt scale;
484  ossimDpt tie;
485 
486  if ( mapProj->isGeographic() )
487  {
488  ossimGpt gpt;
489  mapProj->lineSampleToWorld( theAreaOfInterest.ul(), gpt );
490  tie.x = gpt.lon;
491  tie.y = gpt.lat;
492  scale = mapProj->getDecimalDegreesPerPixel();
493  }
494  else
495  {
497  scale = mapProj->getMetersPerPixel();
498  }
499 
500  // model pixel scale tag 33550:
502  count = 3; // x, y, z
503  type = ossim::OTIFF_DOUBLE;
504  vf.resize( count );
505  vf[0] = scale.x;
506  vf[1] = scale.y;
507  vf[2] = 0.0;
508  writeTiffTag<ossim_float64>( tag, type, count, &vf.front(), arrayWritePos );
509  ++tagCount;
510 
511  // model tie point tag 33992:
513  count = 6; // x, y, z
514  type = ossim::OTIFF_DOUBLE;
515  vf.resize( count );
516  vf[0] = 0.0; // x image point
517  vf[1] = 0.0; // y image point
518  vf[2] = 0.0; // z image point
519  vf[3] = tie.x; // longitude or easting
520  vf[4] = tie.y; // latitude of northing
521  vf[5] = 0.0;
522  writeTiffTag<ossim_float64>( tag, type, count, &vf.front(), arrayWritePos );
523  ++tagCount;
524 
525  // geo key directory tag 34735:
527  count = 0; // set later.
528  type = ossim::OTIFF_SHORT;
529  std::vector<ossim_uint16> vs(0);
530 
531  // No
532  vs.push_back(1);
533  vs.push_back(1);
534  vs.push_back(0);
535  vs.push_back(10); // Updated later.
536 
537  vs.push_back(ossim::OGT_MODEL_TYPE_GEO_KEY); // 1024
538  vs.push_back(0);
539  vs.push_back(1);
540  vs.push_back(mapProj->isGeographic() ? ossim::OMODEL_TYPE_GEOGRAPHIC :
542 
543  vs.push_back(ossim::OGT_RASTER_TYPE_GEO_KEY); // 1025
544  vs.push_back(0);
545  vs.push_back(1);
546  vs.push_back(ossim::OPIXEL_IS_POINT);
547 
548  if ( mapProj->isGeographic() )
549  {
550  vs.push_back(ossim::OGEOGRAPHIC_TYPE_GEO_KEY); // 2048
551  vs.push_back(0);
552  vs.push_back(1);
553  vs.push_back((ossim_uint16)(mapProj->getPcsCode()));
554  }
555 
556  vs.push_back(ossim::OGEOG_GEODETIC_DATUM_GEO_KEY); // 2050
557  vs.push_back(0);
558  vs.push_back(1);
559  vs.push_back((ossim_uint16)(mapProj->getDatum()->epsgCode()));
560 
561  if ( mapProj->isGeographic() )
562  {
563  vs.push_back(ossim::OGEOG_ANGULAR_UNITS_GEO_KEY); // 2054
564  vs.push_back(0);
565  vs.push_back(1);
566  vs.push_back(ossim::OANGULAR_DEGREE);
567  }
568 
569  vs.push_back(ossim::OGEOG_ELLIPSOID_GEO_KEY); // 2056
570  vs.push_back(0);
571  vs.push_back(1);
572  vs.push_back((ossim_uint16)(mapProj->getDatum()->ellipsoid()->getEpsgCode()));
573 
574  // Stored in external OOGEO_DOUBLE_PARAMS_TAG
575  vs.push_back(ossim::OGEOG_SEMI_MAJOR_AXIS); // 2057
576  vs.push_back(ossim::OGEO_DOUBLE_PARAMS_TAG);
577  vs.push_back(1);
578  vs.push_back(0);
579 
580  vs.push_back(ossim::OGEOG_SEMI_MINOR_AXIS); // 2058
581  vs.push_back(ossim::OGEO_DOUBLE_PARAMS_TAG);
582  vs.push_back(1);
583  vs.push_back(1);
584 
585  vs.push_back(ossim::OPROJECTED_CS_TYPE_GEO_KEY); // 3072
586  vs.push_back(0);
587  vs.push_back(1);
588  vs.push_back((ossim_uint16)(mapProj->getPcsCode()));
589 
590  vs.push_back(ossim::OPROJECTION_GEO_KEY); // 3074
591  vs.push_back(0);
592  vs.push_back(1);
593  vs.push_back((ossim_uint16)(mapProj->getPcsCode()));
594 
595  if ( mapProj->isGeographic() == false )
596  {
597  vs.push_back(ossim::OPROJ_LINEAR_UNITS_GEO_KEY); // 3076
598  vs.push_back(0);
599  vs.push_back(1);
600  vs.push_back(ossim::OLINEAR_METER);
601  }
602 
603  count = vs.size();
604  vs[3] = (count / 4) - 1;
605  writeTiffTag<ossim_uint16>( tag, type, count, &vs.front(), arrayWritePos );
606  ++tagCount;
607 
608  // geo double params tag 33550:
610  count = 2; // ellipsoid major, minor axis
611  type = ossim::OTIFF_DOUBLE;
612  vf.resize( count );
613  vf[0] = mapProj->getDatum()->ellipsoid()->a();
614  vf[1] = mapProj->getDatum()->ellipsoid()->b();
615  writeTiffTag<ossim_float64>( tag, type, count, &vf.front(), arrayWritePos );
616  ++tagCount;
617  }
618 
619  // Write trailing zero indicading no more IFDs.
620  ossim_uint64 offsetToNextIfd = 0;
621  m_str->write( (const char*)&offsetToNextIfd, 8 );
622 
623  // Seek back and re-write the tag count.
624  m_str->seekp( 16, std::ios_base::beg );
625  m_str->write( (const char*)&tagCount, 8 );
626 
627  status = m_str->good();
628 
629  return status;
630 }
#define OSSIM_DEFAULT_MAX_PIX_UINT16
virtual const ossimDpt & getDecimalDegreesPerPixel() const
Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing...
ossim_uint16 getTiffSampleFormat() const
Gets the tiff sample format based on scalar type.
bool isTiled() const
ossim_uint32 getEpsgCode() const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
virtual ossim_uint32 epsgCode() const
Definition: ossimDatum.h:59
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossimIrect theAreaOfInterest
virtual bool isGeographic() const
const ossimIpt & ul() const
Definition: ossimIrect.h:274
const double & b() const
unsigned short ossim_uint16
std::ostream * m_str
Definition: ossimWriter.h:289
bool writeSMinSMaxTiffTags(const std::vector< ossim_float64 > &minBands, const std::vector< ossim_float64 > &maxBands, std::streamoff &arrayWritePos)
Writes tags TIFFTAG_SMINSAMPLEVALUE(340) and TIFFTAG_SMAXSAMPLEVALUE(341).
bool writeMinMaxTiffTags(std::streamoff &arrayWritePos)
Writes tags TIFFTAG_MINSAMPLEVALUE(280) and TIFFTAG_MAXSAMPLEVALUE(281).
virtual ossimGpt lineSampleToWorld(const ossimDpt &projectedPoint) const
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
const double & a() const
virtual const ossimDatum * getDatum() const
ossim_float64 lon
Definition: ossimGpt.h:266
virtual void lineSampleToEastingNorthing(const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
unsigned long long ossim_uint64
unsigned int ossim_uint32
virtual const ossimEllipsoid * ellipsoid() const
Definition: ossimDatum.h:60
ossimIpt m_outputTileSize
Definition: ossimWriter.h:295
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
OSSIM_DLL ossim_uint32 getBitsPerPixel(ossimScalarType scalarType)
Get bits per pixel for a given scalar type.
return status
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
ossim_int32 x
Definition: ossimIpt.h:141
ossim_float64 lat
Definition: ossimGpt.h:265
virtual ossimDpt getMetersPerPixel() const

◆ writeTiffTilesBandSeparate()

bool ossimWriter::writeTiffTilesBandSeparate ( std::vector< ossim_uint64 > &  tile_offsets,
std::vector< ossim_uint64 > &  tile_byte_counts,
std::vector< ossim_float64 > &  minBands,
std::vector< ossim_float64 > &  maxBands 
)
private

Writes image data to stream.

Data is in a band separate tile layout(PLANARCONFIG_SEPARATE), i.e. all the red tiles, all the green tiles, all the blue tiles.

Parameters
tile_offsetsInitialized by this with offset for each tile.
tile_byte_countsInitialized by this with the byte count of each tile.
minBandsInitialized by this with the min values for each band.
maxBandsInitialized by this with the max values for each band.
Returns
true on success, false on error.

Definition at line 776 of file ossimWriter.cpp.

Referenced by writeStreamTtbs().

780 {
781  static const char* const MODULE = "ossimWriter::writeToTilesBandSeparate";
782  if ( traceDebug() ) CLOG << " Entered...\n";
783 
784  // Start the sequence at the first tile.
786 
787  // Control flags:
788  bool alignTiles = getAlignTilesFlag();
789  bool flushTiles = getFlushTilesFlag();
790  bool writeBlanks = getWriteBlanksFlag();
791  bool computeMinMax = needsMinMax();
792 
793  // Block size for write:
794  const std::streamsize BLOCK_SIZE = getBlockSize();
795 
799 
800  if (traceDebug())
801  {
803  << "align tiles flag: " << alignTiles
804  << "\nflush tiles flag: " << flushTiles
805  << "\nwrite blanks flag: " << writeBlanks
806  << "\ncompute min max flag: " << computeMinMax
807  << "\nwrite block size: " << BLOCK_SIZE
808  << "\nBANDS: " << BANDS
809  << "\nTILES_WIDE: " << TILES_WIDE
810  << "\nTILES_TOTAL: " << TILES_TOTAL << "\n";
811  }
812 
813  tile_offsets.resize( TILES_TOTAL*BANDS );
814  tile_byte_counts.resize( TILES_TOTAL*BANDS );
815 
817  ossim_int64 ossimTileIndex = 0;
818  ossim_int64 tiffTileIndex = 0;
819  ossim_int64 tileSizeInBytes = 0;
820  ossim_int64 bandOffsetInBytes = 0;
821 
822  //---
823  // Adjust the starting file position to make room for IFD tags, tile offset
824  // and tile byte counts and arrays.
825  //
826  // Assuming:
827  // IFD start = 16, end 512, gives 496 bytes for tags.
828  // Array section start = 512, end is start + (16 * tile_count * bands) + 256 bytes
829  // for geotiff array bytes.
830  //---
831  std::streamsize startPos = 512 + 16 * TILES_TOTAL * BANDS + 256;
832 
833  while ( ossimTileIndex < TILES_TOTAL )
834  {
836  if(!id)
837  {
839  << MODULE << " ERROR:"
840  << "Error returned writing tiff tile: " << ossimTileIndex
841  << "\nNULL Tile from input encountered"
842  << std::endl;
843  return false;
844  }
845 
846  tileStatus = id->getDataObjectStatus();
847 
848  if ( ossimTileIndex == 0 )
849  {
850  tileSizeInBytes = (ossim_int64)id->getSizePerBandInBytes();
851  bandOffsetInBytes = tileSizeInBytes * TILES_TOTAL;
852  }
853 
854  if ( computeMinMax )
855  {
856  if ( (tileStatus == OSSIM_FULL) || (tileStatus == OSSIM_PARTIAL) )
857  {
858  // Compute running min, max.
859  id->computeMinMaxPix(minBands, maxBands);
860  }
861  }
862 
863  // Band loop.
864  for (ossim_int32 band=0; band < BANDS; ++band)
865  {
866  tiffTileIndex = ossimTileIndex + band * TILES_TOTAL;
867 
868  if ( (writeBlanks == true) || (tileStatus == OSSIM_FULL) || (tileStatus == OSSIM_PARTIAL) )
869  {
870  // Grab a pointer to the tile for the band.
871  const char* data = (const char*)id->getBuf(band);
872 
873  // Compress data here(future maybe, i.e. jpeg, j2k...
874 
875  //---
876  // Write the tile.
877  // Note: tiles laid out, all the red tiles, all the green tiles all the
878  // blue tiles.
879  //---
880  if(data)
881  {
882  // Compute the stream position:
883  std::streampos pos = startPos + ossimTileIndex * tileSizeInBytes +
884  band * bandOffsetInBytes;
885 
886  if ( alignTiles )
887  {
888  // Snap to block boundary:
889  std::streampos overflow = pos % BLOCK_SIZE;
890  if ( overflow > 0 )
891  {
892  pos += BLOCK_SIZE - overflow;
893  }
894  }
895 
896  m_str->seekp( pos );
897 
898  if ( m_str->good() )
899  {
900  tile_offsets[ tiffTileIndex ] = (ossim_uint64)pos;
901  tile_byte_counts[ tiffTileIndex ] = (ossim_uint64)tileSizeInBytes;
902 
903  // Write the tile to stream:
904  m_str->write( data, (std::streamsize)tileSizeInBytes);
905 
906  if ( flushTiles )
907  {
908  m_str->flush();
909  }
910 
911  // Check stream:
912  if ( m_str->fail() == true )
913  {
915  << MODULE << " ERROR:\nWrite error on tiff tile: " << ossimTileIndex
916  << std::endl;
917  return false;
918  }
919  }
920  else
921  {
923  << MODULE << " ERROR:\nStream has gone bad!" << std::endl;
924  return false;
925  }
926 
927  }
928  else
929  {
931  << MODULE << " ERROR:\nNull input tile: " << ossimTileIndex
932  << std::endl;
933  return false;
934  }
935  }
936  else
937  {
938  //---
939  // Writing sparse tiff.
940  // Set the offset and byte count to 0 to indicate blank tile.
941  //---
942  if (traceDebug())
943  {
945  << "sparse blank tile[" << tiffTileIndex << "]: " << tiffTileIndex << "\n";
946  }
947  tile_offsets[ tiffTileIndex ] = 0;
948  tile_byte_counts[ tiffTileIndex ] = 0;
949  }
950 
951  } // End of band loop.
952 
953  ++ossimTileIndex;
954 
955  if( needsAborting() )
956  {
957  setPercentComplete(100);
958  break; // Get out...
959  }
960  else if ( ossimTileIndex % TILES_WIDE )
961  {
962  // Output percent complete every row of tiles.
963  double tileNum = ossimTileIndex;
964  double numTiles = TILES_TOTAL;
965  setPercentComplete(tileNum / numTiles * 100.0);
966  }
967 
968  } // End: while ( ossimTileIndex < TILES_TOTAL )
969 
970  if ( traceDebug() ) CLOG << " Exited...\n";
971 
972  return m_str->good();
973 }
#define CLOG
Definition: ossimTrace.h:23
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimRefPtr< ossimImageData > getNextTile(ossim_uint32 resLevel=0)
bool getFlushTilesFlag() const
std::ostream * m_str
Definition: ossimWriter.h:289
virtual ossim_uint32 getSizePerBandInBytes() const
Returns the number of bytes in single band of the tile.
ossimRefPtr< ossimImageSourceSequencer > theInputConnection
ossim_int64 getBlockSize() const
unsigned long long ossim_uint64
bool getWriteBlanksFlag() const
ossim_int64 getNumberOfTilesHorizontal() const
virtual const void * getBuf() const
bool needsMinMax() const
long long ossim_int64
bool getAlignTilesFlag() const
ossimDataObjectStatus
Definitions for data object status.
virtual void setPercentComplete(double percentComplete)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

Member Data Documentation

◆ m_kwl

ossimRefPtr<ossimKeywordlist> ossimWriter::m_kwl
private

◆ m_outputTileSize

ossimIpt ossimWriter::m_outputTileSize
private

Definition at line 295 of file ossimWriter.h.

Referenced by getOutputTileSize(), ossimWriter(), writeStream(), and writeTiffTags().

◆ m_ownsStreamFlag

bool ossimWriter::m_ownsStreamFlag
private

Definition at line 290 of file ossimWriter.h.

Referenced by close(), open(), and setOutputStream().

◆ m_str

std::ostream* ossimWriter::m_str
private

The documentation for this class was generated from the following files: