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

class ossimWatermarkFilter Applies an image or watermark to image. More...

#include <ossimWatermarkFilter.h>

Inheritance diagram for ossimWatermarkFilter:
ossimImageSourceFilter ossimImageSource ossimConnectableObjectListener ossimSource ossimListener ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Public Types

enum  WatermarkMode {
  UPPER_LEFT = 0, UPPER_CENTER = 1, UPPER_RIGHT = 2, CENTER = 3,
  LOWER_LEFT = 4, LOWER_CENTER = 5, LOWER_RIGHT = 6, UNIFORM_DENSE = 7,
  UNIFORM_SPARSE = 8, END = 9
}
 
- 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 Member Functions

 ossimWatermarkFilter ()
 contructor More...
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
 
virtual void initialize ()
 Initializes state of the object from the input connection. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save the state of an object to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Method to the load (recreate) the state of the object from a keyword list. More...
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 Set property. More...
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 Adds this objects properties to the list. More...
 
void getModeList (vector< ossimString > &list) const
 
ossimWatermarkFilter::WatermarkMode getMode () const
 
ossimString getModeString () const
 
void setFilename (const ossimFilename &file)
 Sets theFilename to file. More...
 
void setMode (const ossimString &mode)
 Sets the filter mode. More...
 
void setWeight (ossim_float64 weight)
 Sets the weight. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
- Public Member Functions inherited from ossimImageSourceFilter
 ossimImageSourceFilter (ossimObject *owner=NULL)
 
 ossimImageSourceFilter (ossimImageSource *inputSource)
 
 ossimImageSourceFilter (ossimObject *owner, ossimImageSource *inputSource)
 
virtual void getOutputBandList (std::vector< ossim_uint32 > &bandList) const
 
virtual ossim_uint32 getNumberOfInputBands () const
 
bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void propertyEvent (ossimPropertyEvent &event)
 
virtual void refreshEvent (ossimRefreshEvent &event)
 
- Public Member Functions inherited from ossimImageSource
 ossimImageSource (ossimObject *owner=0)
 
 ossimImageSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimImageSource ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIpt &origin, ossim_uint32 resLevel=0)
 
virtual bool getTile (ossimImageData *result, ossim_uint32 resLevel=0)
 Method to get a tile. More...
 
virtual ossimObjectgetObject ()
 For RTTI support. More...
 
virtual const ossimObjectgetObject () const
 For RTTI support. More...
 
virtual void getDecimationFactor (ossim_uint32 resLevel, ossimDpt &result) const
 Will return the decimation factor for the given resolution level. More...
 
virtual void getDecimationFactors (std::vector< ossimDpt > &decimations) const
 Will return an array of all decimations for each resolution level. More...
 
virtual ossim_uint32 getNumberOfDecimationLevels () const
 Will return the number of resolution levels. More...
 
virtual ossim_uint32 getNumberOfOutputBands () const
 Returns the number of bands in a tile returned from this TileSource. More...
 
virtual ossimScalarType getOutputScalarType () const
 This will be used to query the output pixel type of the tile source. More...
 
virtual ossim_uint32 getTileWidth () const
 Returns the default processing tile width. More...
 
virtual ossim_uint32 getTileHeight () const
 Returns the default processing tile height. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Each band has a null pixel associated with it. More...
 
virtual double getMinPixelValue (ossim_uint32 band=0) const
 Returns the min pixel of the band. More...
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 Returns the max pixel of the band. More...
 
virtual ossimIrect getBoundingRect (ossim_uint32 resLevel=0) const
 This will return the bounding rect of the source. More...
 
virtual void getBoundingRect (ossimIrect &rect, ossim_uint32 resLevel=0) const
 Gets the bounding rectangle of the source. More...
 
virtual void getValidImageVertices (std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if not defined. More...
 
virtual void setImageGeometry (const ossimImageGeometry *geom)
 Default implementation sets geometry of the first input to the geometry specified. More...
 
virtual void saveImageGeometry () const
 Default method to call input's saveImageGeometry. More...
 
virtual void saveImageGeometry (const ossimFilename &geometry_file) const
 Default method to call input's saveImageGeometry. More...
 
virtual bool isIndexedData () const
 
- 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)
 
- 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 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 ossimString getClassName () 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 addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
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 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 &)
 
- 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 ~ossimWatermarkFilter ()
 destructor More...
 
bool allocate ()
 Allocates / recomputes things that are needed. More...
 
bool openWatermarkFile ()
 Attempts to open "theFilename". More...
 
template<class T >
void fill (T dummy)
 Writes watermark(s) to theTile. More...
 
void getIntersectingRects (vector< ossimIrect > &rects)
 Computes the bounding rectangles. More...
 
void getUpperLeftRect (vector< ossimIrect > &rects)
 Addes upper left watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getUpperCenterRect (vector< ossimIrect > &rects)
 Addes upper center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getUpperRightRect (vector< ossimIrect > &rects)
 Addes upper right watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getCenterRect (vector< ossimIrect > &rects)
 Addes center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getLowerLeftRect (vector< ossimIrect > &rects)
 Addes lower left watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getLowerCenterRect (vector< ossimIrect > &rects)
 Addes lower center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getLowerRightRect (vector< ossimIrect > &rects)
 Addes lower right watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getUniformDenseRects (vector< ossimIrect > &rects)
 Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect. More...
 
void getUniformSparceRects (vector< ossimIrect > &rects)
 Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect. More...
 
- Protected Member Functions inherited from ossimImageSourceFilter
virtual ~ossimImageSourceFilter ()
 
- Protected Member Functions inherited from ossimImageSource
 ossimImageSource (const ossimImageSource &rhs)
 
const ossimImageSourceoperator= (const ossimImageSource &)
 
- 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)
 

Protected Attributes

ossimFilename theFilename
 File name of watermark image. More...
 
ossim_float64 theWatermarkWeight
 Normalized between 0.0 and 1.0. More...
 
ossimRefPtr< ossimImageDatatheTile
 The returned tile. More...
 
ossimRefPtr< ossimImageDatatheWatermark
 Tile storage for watermark image. More...
 
ossim_uint32 theWatermarkNumberOfBands
 The number of watermark bands. More...
 
WatermarkMode theMode
 The filter mode. More...
 
ossimIrect theInputBoundingRect
 The bounding rectangle of the input connection. More...
 
ossim_uint32 theInputNumberOfBands
 The number of input bands. More...
 
ossimScalarType theInputScalarType
 The input scalar type. More...
 
bool theDirtyFlag
 Set in the initialize method this instructs the getTile that something has changes and it need to call initialize. More...
 
- Protected Attributes inherited from ossimImageSourceFilter
ossimImageSourcetheInputConnection
 
- 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 ossimListener
bool theListenerEnableFlag
 

Detailed Description

class ossimWatermarkFilter Applies an image or watermark to image.

Positioning is based on mode. Density is base on alpha weight.

Definition at line 31 of file ossimWatermarkFilter.h.

Member Enumeration Documentation

◆ WatermarkMode

Constructor & Destructor Documentation

◆ ossimWatermarkFilter()

ossimWatermarkFilter::ossimWatermarkFilter ( )

contructor

Definition at line 45 of file ossimWatermarkFilter.cpp.

References ossimSource::theEnableFlag.

46  :
49  theTile(NULL),
50  theWatermark(NULL),
53  theDirtyFlag(true)
54 {
55  theEnableFlag = true;
56 
57  if (traceDebug())
58  {
60  << "ossimPixelFlipper::ossimPixelFlipper" << std::endl;
61 #ifdef OSSIM_ID_ENABLED
63  << "OSSIM_ID: " << OSSIM_ID << std::endl;
64 #endif
65  }
66 }
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
bool theEnableFlag
Definition: ossimSource.h:62
WatermarkMode theMode
The filter mode.
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
const ossim_float64 DEFAULT_WEIGHT
ossimRefPtr< ossimImageData > theTile
The returned tile.
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossimFilename theFilename
File name of watermark image.
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool theDirtyFlag
Set in the initialize method this instructs the getTile that something has changes and it need to cal...

◆ ~ossimWatermarkFilter()

ossimWatermarkFilter::~ossimWatermarkFilter ( )
protectedvirtual

destructor

Definition at line 68 of file ossimWatermarkFilter.cpp.

References theTile, and theWatermark.

69 {
70  // Dereference tiles and force a delete if last reference.
71  theWatermark = NULL;
72  theTile = NULL;
73 }
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
ossimRefPtr< ossimImageData > theTile
The returned tile.

Member Function Documentation

◆ allocate()

bool ossimWatermarkFilter::allocate ( )
protected

Allocates / recomputes things that are needed.

Clears theDirtyFlag by setting it to false on success.

Returns
true on success, false on error.

Definition at line 730 of file ossimWatermarkFilter.cpp.

References ossimImageDataFactory::create(), ossimImageSource::getBoundingRect(), ossimImageData::getNumberOfBands(), ossimImageSource::getNumberOfOutputBands(), ossimImageSource::getOutputScalarType(), ossimRectilinearDataObject::getScalarType(), ossimImageData::initialize(), ossimImageDataFactory::instance(), openWatermarkFile(), theDirtyFlag, theInputBoundingRect, ossimImageSourceFilter::theInputConnection, theInputNumberOfBands, theInputScalarType, theTile, theWatermark, and ossimRefPtr< T >::valid().

Referenced by getTile().

731 {
732  // Capture the bounding rect:
734 
735  // Capture the scalar type:
737 
738  // Capture the number of bands:
740 
741  //---
742  // Check the watermark scalar type.
743  //---
744  if (theWatermark.valid())
745  {
747  {
748  //---
749  // We'll need to make a new one with a scalar remapper after it.
750  //---
751  theWatermark = NULL; // We'll need to make a new one.
752  }
753  }
754 
755  //---
756  // Make a new watermark tile. This will do a scalar remap if needed.
757  // If we don't have a watermark no point in going on...
758  //---
759  if (!theWatermark)
760  {
761  if (openWatermarkFile() == false)
762  {
763  return false;
764  }
765  }
766 
767  if (theTile.valid())
768  {
771  {
772  theTile = NULL; // We'll need to make a new one.
773  }
774  }
775 
776  // Make a new output tile if we need to.
777  if (!theTile)
778  {
781  if (theTile.valid())
782  {
783  theTile->initialize();
784  }
785  else
786  {
787  return false;
788  }
789  }
790 
791  //---
792  // If we get here things are good so clear the dirty flag so we don't
793  // get called again needlessly.
794  //---
795  theDirtyFlag = false;
796 
797  return true;
798 }
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual ossim_uint32 getNumberOfBands() 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
bool openWatermarkFile()
Attempts to open "theFilename".
ossimScalarType theInputScalarType
The input scalar type.
virtual void initialize()
Initialize the data buffer.
static ossimImageDataFactory * instance()
ossim_uint32 theInputNumberOfBands
The number of input bands.
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
ossimImageSource * theInputConnection
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual ossimScalarType getScalarType() const
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
bool theDirtyFlag
Set in the initialize method this instructs the getTile that something has changes and it need to cal...

◆ fill()

template<class T >
void ossimWatermarkFilter::fill ( dummy)
protected

Writes watermark(s) to theTile.

Performs theTile->validate() at the end if theTile was touched.

Definition at line 226 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getBuf(), ossimImageData::getImageRectangle(), getIntersectingRects(), ossimImageData::getMaxPix(), ossimImageData::getMinPix(), ossimImageData::getNullPix(), ossimImageData::getWidth(), ossimIrect::height(), theInputBoundingRect, theInputNumberOfBands, theTile, theWatermark, theWatermarkNumberOfBands, theWatermarkWeight, ossimIrect::ul(), ossimImageData::validate(), ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by getTile().

227 {
228  const ossimIrect TILE_RECT = theTile->getImageRectangle();
229 
230  // We will only fill data within the input bounding rect.
231  const ossimIrect CLIPPED_TILE_RECT =
232  TILE_RECT.clipToRect(theInputBoundingRect);
233 
234  // Get the bounding rectangles.
235  vector<ossimIrect> rects(0);
236  getIntersectingRects(rects);
237 
238  if (rects.size() == 0)
239  {
240  return;
241  }
242 
243  //---
244  // Have watermark rectangles that intersect this tile so we need to process.
245  //---
246  ossim_uint32 band = 0;
247  ossim_float64 inputPixWeight = 1.0 - theWatermarkWeight;
248 
249  // Get a pointers to the watermark buffers (wmBuf) and nulls wn.
250  T** wmBuf = new T*[theWatermarkNumberOfBands];
251  for (band = 0; band < theWatermarkNumberOfBands; ++band)
252  {
253  wmBuf[band] = static_cast<T*>(theWatermark->getBuf(band));
254  }
255 
256  // Get a pointers to the output tile buffers and nulls in.
257  T** otBuf = new T*[theInputNumberOfBands];
258  for (band = 0; band < theInputNumberOfBands; ++band)
259  {
260  otBuf[band] = static_cast<T*>(theTile->getBuf(band));
261  }
262 
263  // Get the width of the buffers for indexing.
264  ossim_int32 wmWidth = static_cast<ossim_int32>(theWatermark->getWidth());
265  ossim_int32 otWidth = static_cast<ossim_int32>(theTile->getWidth());
266 
267  const ossim_float64* wmNull = theWatermark->getNullPix();
268  const ossim_float64* otMin = theTile->getMinPix();
269  const ossim_float64* otMax = theTile->getMaxPix();
270  const ossim_float64* otNull = theTile->getNullPix();
271 
272 
273  // Control loop through intersecting rectangles.
274  vector<ossimIrect>::const_iterator i = rects.begin();
275  while (i != rects.end())
276  {
277  if ( (*i).intersects(CLIPPED_TILE_RECT) )
278  {
279  //---
280  // This is the rectangle we want to fill relative to requesting
281  // image space.
282  //---
283  const ossimIrect CLIPPED_WATERMARRK_RECT =
284  (*i).clipToRect(CLIPPED_TILE_RECT);
285 
286  ossim_int32 clipHeight = CLIPPED_WATERMARRK_RECT.height();
287  ossim_int32 clipWidth = CLIPPED_WATERMARRK_RECT.width();
288 
289  // Compute the starting offset into the wmBuf and otBuf.
290  ossim_int32 wmOffset =
291  (CLIPPED_WATERMARRK_RECT.ul().y - (*i).ul().y) * wmWidth +
292  CLIPPED_WATERMARRK_RECT.ul().x - (*i).ul().x;
293  ossim_int32 otOffset =
294  (CLIPPED_WATERMARRK_RECT.ul().y - TILE_RECT.ul().y)* otWidth +
295  CLIPPED_WATERMARRK_RECT.ul().x - TILE_RECT.ul().x;
296 
297  // Line loop...
298  for (ossim_int32 line = 0; line < clipHeight; ++line)
299  {
300  // Sample loop...
301  for (ossim_int32 sample = 0; sample < clipWidth; ++sample)
302  {
303  // Output band control loop until all output bands are filled.
304  ossim_uint32 otBand = 0;
305  while (otBand < theInputNumberOfBands)
306  {
307  // Band loop through the watermark.
308  for (ossim_uint32 wmBand = 0;
309  wmBand < theWatermarkNumberOfBands;
310  ++wmBand)
311  {
312  if (wmBuf[wmBand][wmOffset+sample] != wmNull[wmBand])
313  {
314  // Apply the weight to the input pixel.
315  ossim_float64 p1 =
316  (otBuf[otBand][otOffset+sample] != otNull[otBand]) ?
317  otBuf[otBand][otOffset+sample] * inputPixWeight :
318  0.0;
319 
320  // Apply the Weight to the watermark pixel.
321  ossim_float64 p2 =
322  wmBuf[wmBand][wmOffset+sample]*theWatermarkWeight;
323 
324  // Add them up.
325  ossim_float64 p3 = p1 + p2;
326 
327  // Cast to output type with range checking.
328  otBuf[otBand][otOffset+sample] = static_cast<T>(
329  ( (p3 >= otMin[otBand]) ?
330  (p3 < otMax[otBand] ? p3 : otMax[otBand]) :
331  otNull[otBand]) );
332  }
333  ++otBand;
334 
335  // We stop when we reach here. All output bands filled.
336  if (otBand == theInputNumberOfBands)
337  {
338  break;
339  }
340 
341  } // End of band through watermark.
342 
343  } // End of outer band loop.
344 
345  } // End of sample loop.
346 
347  wmOffset += wmWidth;
348  otOffset += otWidth;
349 
350  } // End of line loop.
351 
352  } // End "if ( (*i).intersects(TILE_RECT) )"
353 
354  ++i; // Go to next rectangle to fill if any.
355 
356  } // End of "while (i != rects.end())"
357 
358  // Clean up.
359  delete [] wmBuf;
360  delete [] otBuf;
361 
362  theTile->validate();
363 }
virtual ossim_uint32 getWidth() const
virtual const ossim_float64 * getMaxPix() const
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
double ossim_float64
ossim_uint32 theInputNumberOfBands
The number of input bands.
virtual ossimDataObjectStatus validate() const
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
void getIntersectingRects(vector< ossimIrect > &rects)
Computes the bounding rectangles.
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual ossimIrect getImageRectangle() const
ossim_uint32 theWatermarkNumberOfBands
The number of watermark bands.
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual const ossim_float64 * getMinPix() const
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
ossim_int32 x
Definition: ossimIpt.h:141
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
int ossim_int32

◆ getCenterRect()

void ossimWatermarkFilter::getCenterRect ( vector< ossimIrect > &  rects)
protected

Addes center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 468 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by getIntersectingRects().

469 {
470  // First clip the rect to the bounding image rectangle.
471  const ossimIrect CLIP_RECT =
473  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
474  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
475  ossim_uint32 inputWidth = theInputBoundingRect.width();
476  ossim_uint32 inputHeight = theInputBoundingRect.height();
477  ossimIpt origin = theInputBoundingRect.ul();
478 
479  // Input wider than watermark so center.
480  if (inputWidth > watermarkWidth)
481  {
482  ossim_int32 offset =
483  static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
484  origin.x = origin.x + offset;
485  }
486  // Input higher than watermark so center.
487  if (inputHeight > watermarkHeight)
488  {
489  ossim_int32 offset =
490  static_cast<ossim_int32>((inputHeight - watermarkHeight) / 2);
491  origin.y = origin.y + offset;
492  }
493 
494  theWatermark->setOrigin(origin);
495 
497  if (r.intersects(CLIP_RECT))
498  {
499  rects.push_back(r);
500  }
501 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getDescription()

ossimString ossimWatermarkFilter::getDescription ( ) const
virtual
Returns
Descriptive name of filter.

Reimplemented from ossimConnectableObject.

Definition at line 85 of file ossimWatermarkFilter.cpp.

References getLongName(), and getModeList().

86 {
87  ossimString description;
88  description = getLongName();
89  description += "\n";
90  description += "Valid modes:\n";
91 
92  vector<ossimString> list;
93  getModeList(list);
94 
95  vector<ossimString>::const_iterator i = list.begin();
96  while (i != list.end())
97  {
98  description +=(*i);
99  description += "\n";
100  ++i;
101  }
102 
103  return description;
104 }
void getModeList(vector< ossimString > &list) const
virtual ossimString getLongName() const

◆ getIntersectingRects()

void ossimWatermarkFilter::getIntersectingRects ( vector< ossimIrect > &  rects)
protected

Computes the bounding rectangles.

These are the rectangles in image space of the input connection to paint the watermark(s) on. The start of each rectangle will be the start of where "theWatermark" is painted.

Definition at line 365 of file ossimWatermarkFilter.cpp.

References CENTER, getCenterRect(), getLowerCenterRect(), getLowerLeftRect(), getLowerRightRect(), getUniformDenseRects(), getUniformSparceRects(), getUpperCenterRect(), getUpperLeftRect(), getUpperRightRect(), LOWER_CENTER, LOWER_LEFT, LOWER_RIGHT, theMode, UNIFORM_DENSE, UNIFORM_SPARSE, UPPER_CENTER, UPPER_LEFT, and UPPER_RIGHT.

Referenced by fill().

366 {
367  switch(theMode)
368  {
369  case UPPER_LEFT:
370  getUpperLeftRect(rects);
371  break;
372  case UPPER_CENTER:
373  getUpperCenterRect(rects);
374  break;
375  case UPPER_RIGHT:
376  getUpperRightRect(rects);
377  break;
378  case CENTER:
379  getCenterRect(rects);
380  break;
381  case LOWER_LEFT:
382  getLowerLeftRect(rects);
383  break;
384  case LOWER_CENTER:
385  getLowerCenterRect(rects);
386  break;
387  case LOWER_RIGHT:
388  getLowerRightRect(rects);
389  break;
390  case UNIFORM_DENSE:
391  getUniformDenseRects(rects);
392  break;
393  case UNIFORM_SPARSE:
394  getUniformSparceRects(rects);
395  break;
396  default:
397  break;
398  }
399 }
void getUpperRightRect(vector< ossimIrect > &rects)
Addes upper right watermark rectangle to rects if it intersects theTile rect clipped to input boundin...
void getUniformSparceRects(vector< ossimIrect > &rects)
Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect...
void getUpperCenterRect(vector< ossimIrect > &rects)
Addes upper center watermark rectangle to rects if it intersects theTile rect clipped to input boundi...
WatermarkMode theMode
The filter mode.
void getLowerLeftRect(vector< ossimIrect > &rects)
Addes lower left watermark rectangle to rects if it intersects theTile rect clipped to input bounding...
void getUniformDenseRects(vector< ossimIrect > &rects)
Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect...
void getCenterRect(vector< ossimIrect > &rects)
Addes center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rec...
void getLowerCenterRect(vector< ossimIrect > &rects)
Addes lower center watermark rectangle to rects if it intersects theTile rect clipped to input boundi...
void getLowerRightRect(vector< ossimIrect > &rects)
Addes lower right watermark rectangle to rects if it intersects theTile rect clipped to input boundin...
void getUpperLeftRect(vector< ossimIrect > &rects)
Addes upper left watermark rectangle to rects if it intersects theTile rect clipped to input bounding...

◆ getLongName()

ossimString ossimWatermarkFilter::getLongName ( ) const
virtual
Returns
Long name of filter.

Reimplemented from ossimObject.

Definition at line 80 of file ossimWatermarkFilter.cpp.

Referenced by getDescription().

81 {
82  return ossimString("Watermark Filter - Applies watermark image onto getTile Request.");
83 }

◆ getLowerCenterRect()

void ossimWatermarkFilter::getLowerCenterRect ( vector< ossimIrect > &  rects)
protected

Addes lower center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 529 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by getIntersectingRects().

530 {
531  // First clip the rect to the bounding image rectangle.
532  const ossimIrect CLIP_RECT =
534  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
535  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
536  ossim_uint32 inputWidth = theInputBoundingRect.width();
537  ossim_uint32 inputHeight = theInputBoundingRect.height();
538  ossimIpt origin = theInputBoundingRect.ul();
539 
540  // Input wider than watermark so center.
541  if (inputWidth > watermarkWidth)
542  {
543  ossim_int32 offset =
544  static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
545  origin.x = origin.x + offset;
546  }
547  // Input higher than watermark so apply offset.
548  if (inputHeight > watermarkHeight)
549  {
550  ossim_int32 offset =
551  static_cast<ossim_int32>(inputHeight - watermarkHeight);
552  origin.y = origin.y + offset;
553  }
554 
555  theWatermark->setOrigin(origin);
557  if (r.intersects(CLIP_RECT))
558  {
559  rects.push_back(r);
560  }
561 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getLowerLeftRect()

void ossimWatermarkFilter::getLowerLeftRect ( vector< ossimIrect > &  rects)
protected

Addes lower left watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 503 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), and ossimIpt::y.

Referenced by getIntersectingRects().

504 {
505  // First clip the rect to the bounding image rectangle.
506  const ossimIrect CLIP_RECT =
508  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
509  ossim_uint32 inputHeight = theInputBoundingRect.height();
510  ossimIpt origin = theInputBoundingRect.ul();
511 
512  // Input higher than watermark so apply offset.
513  if (inputHeight > watermarkHeight)
514  {
515  ossim_int32 offset =
516  static_cast<ossim_int32>(inputHeight - watermarkHeight);
517  origin.y = origin.y + offset;
518  }
519 
520  theWatermark->setOrigin(origin);
521 
523  if (r.intersects(CLIP_RECT))
524  {
525  rects.push_back(r);
526  }
527 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
int ossim_int32

◆ getLowerRightRect()

void ossimWatermarkFilter::getLowerRightRect ( vector< ossimIrect > &  rects)
protected

Addes lower right watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 563 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by getIntersectingRects().

564 {
565  // First clip the rect to the bounding image rectangle.
566  const ossimIrect CLIP_RECT =
568  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
569  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
570  ossim_uint32 inputWidth = theInputBoundingRect.width();
571  ossim_uint32 inputHeight = theInputBoundingRect.height();
572  ossimIpt origin = theInputBoundingRect.ul();
573 
574  // Input wider than watermark so center.
575  if (inputWidth > watermarkWidth)
576  {
577  ossim_int32 offset =
578  static_cast<ossim_int32>(inputWidth - watermarkWidth);
579  origin.x = origin.x + offset;
580  }
581  // Input higher than watermark so apply offset.
582  if (inputHeight > watermarkHeight)
583  {
584  ossim_int32 offset =
585  static_cast<ossim_int32>(inputHeight - watermarkHeight);
586  origin.y = origin.y + offset;
587  }
588 
589  theWatermark->setOrigin(origin);
591  if (r.intersects(CLIP_RECT))
592  {
593  rects.push_back(r);
594  }
595 
596 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getMode()

ossimWatermarkFilter::WatermarkMode ossimWatermarkFilter::getMode ( ) const
Returns
theMode

Definition at line 1034 of file ossimWatermarkFilter.cpp.

References theMode.

1035 {
1036  return theMode;
1037 }
WatermarkMode theMode
The filter mode.

◆ getModeList()

void ossimWatermarkFilter::getModeList ( vector< ossimString > &  list) const
Parameters
listList initialized with watermark mode strings.
Note
This method clears the "list" prior to stuffing.

Definition at line 1019 of file ossimWatermarkFilter.cpp.

References END.

Referenced by getDescription().

1020 {
1021  list.clear();
1022  list.resize(ossimWatermarkFilter::END);
1023  list[0] = ossimString("upper_left");
1024  list[1] = ossimString("upper_center");
1025  list[2] = ossimString("upper_right");
1026  list[3] = ossimString("center");
1027  list[4] = ossimString("lower_left");
1028  list[5] = ossimString("lower_center");
1029  list[6] = ossimString("lower_right");
1030  list[7] = ossimString("uniform_dense");
1031  list[8] = ossimString("uniform_sparse");
1032 }

◆ getModeString()

ossimString ossimWatermarkFilter::getModeString ( ) const
Returns
theMode as a string like "upper_left".

Definition at line 1039 of file ossimWatermarkFilter.cpp.

References CENTER, LOWER_CENTER, LOWER_LEFT, LOWER_RIGHT, theMode, UNIFORM_DENSE, UNIFORM_SPARSE, UPPER_CENTER, UPPER_LEFT, and UPPER_RIGHT.

Referenced by print().

1040 {
1041  switch(theMode)
1042  {
1043  case UPPER_LEFT:
1044  return ossimString("upper_left");
1045  case UPPER_CENTER:
1046  return ossimString("upper_center");
1047  case UPPER_RIGHT:
1048  return ossimString("upper_right");
1049  case CENTER:
1050  return ossimString("center");
1051  case LOWER_LEFT:
1052  return ossimString("lower_left");
1053  case LOWER_CENTER:
1054  return ossimString("lower_center");
1055  case LOWER_RIGHT:
1056  return ossimString("lower_right");
1057  case UNIFORM_DENSE:
1058  return ossimString("uniform_dense");
1059  case UNIFORM_SPARSE:
1060  return ossimString("uniform_sparse");
1061  default:
1062  break;
1063  }
1064 
1065  return ossimString("UNKNOWN_MODE");
1066 }
WatermarkMode theMode
The filter mode.

◆ getProperty()

ossimRefPtr< ossimProperty > ossimWatermarkFilter::getProperty ( const ossimString name) const
virtual
Parameters
Theproperty to get as a string like "watermark_mode".
Returns
ossimRefPt<ossimProperty> holding pointer to ossimProperty matching string or null pointer if string does not match.
Note
Internal pointer can be null so callers should check prior to accessing like: ossimRefPtr<ossimProperty> p = myFilter->getProperty(ossimString("foo")); if (p.valid() == NULL) { some_error; }

Reimplemented from ossimImageSourceFilter.

Definition at line 948 of file ossimWatermarkFilter.cpp.

References ossimKeywordNames::FILENAME_KW, ossimFilenameProperty::ossimFilenamePropertyIoType_INPUT, ossimProperty::setCacheRefreshBit(), ossimFilenameProperty::setIoType(), and theFilename.

950 {
951  // Lock for the length of this method.
952  if (name == ossimKeywordNames::FILENAME_KW)
953  {
954  ossimFilenameProperty* ofp =
957  ofp->setCacheRefreshBit();
959  }
960  else if (name == WATERMARK_MODE_KW)
961  {
962  vector<ossimString> constraintList;
963  getModeList(constraintList);
964 
966  new ossimStringProperty(name,
967  getModeString(),
968  false,
969  constraintList);
970  p->setCacheRefreshBit();
971  return ossimRefPtr<ossimProperty>(p);
972  }
973  else if (name == WEIGHT_KW)
974  {
975  ossimProperty* p =
976  new ossimNumericProperty(name,
978  p->setCacheRefreshBit();
979  return ossimRefPtr<ossimProperty>(p);
980  }
981 
983 }
ossimString getModeString() const
void getModeList(vector< ossimString > &list) const
static ossimString toString(bool aValue)
Numeric to string methods.
void setIoType(ossimFilenamePropertyIoType ioType)
ossimFilename theFilename
File name of watermark image.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
static const char * FILENAME_KW
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
void setCacheRefreshBit()

◆ getPropertyNames()

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

Adds this objects properties to the list.

Parameters
propertyNamesArray to add to.
Note
This method does not clear propertyNames prior to adding it's names.

Reimplemented from ossimImageSourceFilter.

Definition at line 1010 of file ossimWatermarkFilter.cpp.

References ossimKeywordNames::FILENAME_KW.

1012 {
1013  propertyNames.push_back(ossimKeywordNames::FILENAME_KW);
1014  propertyNames.push_back(WATERMARK_MODE_KW);
1015  propertyNames.push_back(WEIGHT_KW);
1017 }
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
static const char * FILENAME_KW

◆ getShortName()

ossimString ossimWatermarkFilter::getShortName ( ) const
virtual
Returns
Short name of filter.

Reimplemented from ossimObject.

Definition at line 75 of file ossimWatermarkFilter.cpp.

76 {
77  return ossimString("Watermark Filter");
78 }

◆ getTile()

ossimRefPtr< ossimImageData > ossimWatermarkFilter::getTile ( const ossimIrect tile_rect,
ossim_uint32  resLevel = 0 
)
virtual
Parameters
tile_rectRectangle to fill tile with.
resLevelReduced resolution level to grab from.
Returns
ossimRefPtr<ossimImageData> This is tile that was filled with tile_rect.
Note
Callers should check the ossimRefPtr::valid method. The internal pointer of the ossimRefPtr<ossimImageData> can be null if the tile_rect did not intersect the input connection's bounding rectangle.

Reimplemented from ossimImageSource.

Definition at line 106 of file ossimWatermarkFilter.cpp.

References allocate(), fill(), ossimRefPtr< T >::get(), ossimDataObject::getDataObjectStatus(), ossimRectilinearDataObject::getScalarType(), ossimImageSource::getTile(), ossimIrect::intersects(), ossimImageData::loadTile(), ossimImageData::makeBlank(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_NULL, OSSIM_SCALAR_UNKNOWN, OSSIM_SINT16, OSSIM_SINT32, OSSIM_SINT8, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), ossimNotifyLevel_WARN, ossimImageData::setImageRectangle(), theDirtyFlag, ossimSource::theEnableFlag, theInputBoundingRect, ossimImageSourceFilter::theInputConnection, theTile, theWatermarkWeight, and ossimRefPtr< T >::valid().

108 {
109  // Lock for the length of this method.
110  // Check for input.
111  if (!theInputConnection)
112  {
113  if (theTile.valid())
114  {
115  theTile->setImageRectangle(tile_rect);
116  theTile->makeBlank();
117  }
118  return theTile;
119  }
120 
121  // Fetch a tile from from the input source.
122  ossimRefPtr<ossimImageData> inputTile =
123  theInputConnection->getTile(tile_rect, resLevel);
124 
125  // Check for bypass.
126  if (theEnableFlag == false) return inputTile;
127 
128  // Check for weight being 0.0.
129  if (theWatermarkWeight == 0.0) return inputTile;
130 
131  //---
132  // Check for dirty state.
133  // Note: This is set in initialize if something changes.
134  //---
135  if (theDirtyFlag == true)
136  {
137  if (allocate() == false) // Something not right if false.
138  {
139  return inputTile;
140  }
141  }
142 
143  // We will only watermark (process) within the input bounding rectangle.
144  if (tile_rect.intersects(theInputBoundingRect) == false)
145  {
146  return inputTile;
147  }
148 
149  // Capture the rectangle and blank out theTile.
150  theTile->setImageRectangle(tile_rect);
151 
152  if (inputTile.valid() &&
153  (inputTile->getDataObjectStatus() != OSSIM_NULL))
154  {
155  // Copy the inputTile to theTile.
156  theTile->loadTile(inputTile.get());
157  }
158  else
159  {
160  theTile->makeBlank();
161  }
162 
163  // Write the watermarks...
164  switch(theTile->getScalarType())
165  {
166  case OSSIM_UINT8:
167  {
168  fill(ossim_uint8(0));
169  break;
170  }
171  case OSSIM_SINT8:
172  {
173  fill(ossim_sint8(0));
174  break;
175  }
176  case OSSIM_USHORT11:
177  case OSSIM_USHORT12:
178  case OSSIM_USHORT13:
179  case OSSIM_USHORT14:
180  case OSSIM_USHORT15:
181  case OSSIM_UINT16:
182  {
183  fill(ossim_uint16(0));
184  break;
185  }
186  case OSSIM_SINT16:
187  {
188  fill(ossim_sint16(0));
189  break;
190  }
191  case OSSIM_UINT32:
192  {
193  fill(ossim_uint32(0));
194  break;
195  }
196  case OSSIM_SINT32:
197  {
198  fill(ossim_sint32(0));
199  break;
200  }
201  case OSSIM_FLOAT32:
203  {
204  fill(ossim_float32(0));
205  break;
206  }
207  case OSSIM_FLOAT64:
209  {
210  fill(ossim_float32(0));
211  break;
212  }
214  default:
215  {
217  << "Scalar type = " << theTile->getScalarType()
218  << " Not supported by ossimWatermarkFilter" << std::endl;
219  return inputTile;
220  }
221  }
222 
223  return theTile;
224 }
16 bit unsigned integer (15 bits used)
8 bit signed integer
64 bit floating point
virtual void setImageRectangle(const ossimIrect &rect)
16 bit unsigned integer
bool theEnableFlag
Definition: ossimSource.h:62
bool valid() const
Definition: ossimRefPtr.h:75
float ossim_float32
16 bit signed integer
virtual ossimDataObjectStatus getDataObjectStatus() const
16 bit unsigned integer (14 bits used)
signed char ossim_sint8
16 bit unsigned integer (13 bits used)
32 bit floating point
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
unsigned short ossim_uint16
32 bit unsigned integer
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
signed short ossim_sint16
32 bit signed integer
ossimImageSource * theInputConnection
unsigned int ossim_uint32
32 bit normalized floating point
signed int ossim_sint32
ossimRefPtr< ossimImageData > theTile
The returned tile.
void fill(T dummy)
Writes watermark(s) to theTile.
virtual ossimScalarType getScalarType() const
virtual void makeBlank()
Initializes data to null pixel values.
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
8 bit unsigned integer
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool allocate()
Allocates / recomputes things that are needed.
bool theDirtyFlag
Set in the initialize method this instructs the getTile that something has changes and it need to cal...
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)

◆ getUniformDenseRects()

void ossimWatermarkFilter::getUniformDenseRects ( vector< ossimIrect > &  rects)
protected

Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect.

This will repeat the watermark throughout the input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 598 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, x, ossimIpt::y, and y.

Referenced by getIntersectingRects().

599 {
600  // First clip the rect to the bounding image rectangle.
601  const ossimIrect CLIP_RECT =
603  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
604  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
605  ossim_uint32 inputWidth = theInputBoundingRect.width();
606  ossim_uint32 inputHeight = theInputBoundingRect.height();
607 
608  ossim_uint32 watermarksHigh = inputHeight / watermarkHeight;
609  if (inputHeight % watermarkHeight) ++watermarksHigh;
610 
611  ossim_uint32 watermarksWide = inputWidth / watermarkWidth;
612  if (inputWidth % watermarkWidth) ++watermarksWide;
613 
614  ossim_int32 xOffset = static_cast<ossim_int32>(watermarkWidth);
615  ossim_int32 yOffset = static_cast<ossim_int32>(watermarkHeight);
616 
617  ossimIpt origin = theInputBoundingRect.ul();
618 
619  for (ossim_uint32 y = 0; y < watermarksHigh; ++y)
620  {
621  for (ossim_uint32 x = 0; x < watermarksWide; ++x)
622  {
623  theWatermark->setOrigin(origin);
625  if (r.intersects(CLIP_RECT))
626  {
627  rects.push_back(r);
628  }
629  origin.x = origin.x + xOffset;
630  }
631  origin.y = origin.y + yOffset;
632  origin.x = theInputBoundingRect.ul().x;
633  }
634 }
ossim_uint32 x
ossim_uint32 y
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getUniformSparceRects()

void ossimWatermarkFilter::getUniformSparceRects ( vector< ossimIrect > &  rects)
protected

Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect.

This will repeat the watermark sparsly throughout the input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 636 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::height(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), ossimIpt::x, x, ossimIpt::y, and y.

Referenced by getIntersectingRects().

637 {
638  // First clip the rect to the bounding image rectangle.
639  const ossimIrect CLIP_RECT =
641  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
642  ossim_uint32 watermarkHeight = theWatermark->getImageRectangle().height();
643  ossim_uint32 inputWidth = theInputBoundingRect.width();
644  ossim_uint32 inputHeight = theInputBoundingRect.height();
645  ossim_uint32 gapWidth = watermarkWidth/2;
646  ossim_uint32 gapHeight = watermarkHeight/2;
647 
648  ossim_uint32 watermarksHigh = inputHeight/(watermarkHeight+gapHeight);
649  if (inputHeight % watermarkHeight) ++watermarksHigh;
650 
651  ossim_uint32 watermarksWide = inputWidth/(watermarkWidth+gapWidth);
652  if (inputWidth % watermarkWidth) ++watermarksWide;
653 
654  ossim_int32 xOffset = static_cast<ossim_int32>(watermarkWidth + gapWidth);
655  ossim_int32 yOffset = static_cast<ossim_int32>(watermarkHeight + gapHeight);
656 
657  ossimIpt origin = theInputBoundingRect.ul();
658 
659  for (ossim_uint32 y = 0; y < watermarksHigh; ++y)
660  {
661  for (ossim_uint32 x = 0; x < watermarksWide; ++x)
662  {
663  theWatermark->setOrigin(origin);
665  if (r.intersects(CLIP_RECT))
666  {
667  rects.push_back(r);
668  }
669  origin.x = origin.x + xOffset;
670  }
671  origin.y = origin.y + yOffset;
672  origin.x = theInputBoundingRect.ul().x;
673  }
674 }
ossim_uint32 x
ossim_uint32 y
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getUpperCenterRect()

void ossimWatermarkFilter::getUpperCenterRect ( vector< ossimIrect > &  rects)
protected

Addes upper center watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 414 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), and ossimIpt::x.

Referenced by getIntersectingRects().

415 {
416  // First clip the rect to the bounding image rectangle.
417  const ossimIrect CLIP_RECT =
419  ossim_uint32 watermarkWidth = theWatermark->getImageRectangle().width();
420  ossim_uint32 inputWidth = theInputBoundingRect.width();
421  ossimIpt origin = theInputBoundingRect.ul();
422 
423  // Input wider than watermark so center.
424  if (inputWidth > watermarkWidth)
425  {
426  ossim_int32 offset =
427  static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
428  origin.x = origin.x + offset;
429  }
430 
431  theWatermark->setOrigin(origin);
432 
434  if (r.intersects(CLIP_RECT))
435  {
436  rects.push_back(r);
437  }
438 }
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ getUpperLeftRect()

void ossimWatermarkFilter::getUpperLeftRect ( vector< ossimIrect > &  rects)
protected

Addes upper left watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 401 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, and ossimIrect::ul().

Referenced by getIntersectingRects().

402 {
403  // First clip the rect to the bounding image rectangle.
404  const ossimIrect CLIP_RECT =
408  if (r.intersects(CLIP_RECT))
409  {
410  rects.push_back(r);
411  }
412 }
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
virtual ossimIrect getImageRectangle() const
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.

◆ getUpperRightRect()

void ossimWatermarkFilter::getUpperRightRect ( vector< ossimIrect > &  rects)
protected

Addes upper right watermark rectangle to rects if it intersects theTile rect clipped to input bounding rect.

Parameters
rectsArray to add rect to.

Definition at line 440 of file ossimWatermarkFilter.cpp.

References ossimIrect::clipToRect(), ossimImageData::getImageRectangle(), ossimIrect::intersects(), ossimImageData::setOrigin(), theInputBoundingRect, theTile, theWatermark, ossimIrect::ul(), ossimIrect::width(), and ossimIpt::x.

Referenced by getIntersectingRects().

441 {
442  // First clip the rect to the bounding image rectangle.
443  const ossimIrect CLIP_RECT =
445  ossim_uint32 watermarkWidth =
447  ossim_uint32 inputWidth = theInputBoundingRect.width();
448 
449  ossimIpt origin = theInputBoundingRect.ul();
450 
451  // Input wider than watermark so center.
452  if (inputWidth > watermarkWidth)
453  {
454  ossim_int32 offset =
455  static_cast<ossim_int32>(inputWidth - watermarkWidth);
456  origin.x = origin.x + offset;
457  }
458 
459  theWatermark->setOrigin(origin);
460 
462  if (r.intersects(CLIP_RECT))
463  {
464  rects.push_back(r);
465  }
466 }
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
ossimRefPtr< ossimImageData > theTile
The returned tile.
virtual void setOrigin(const ossimIpt &origin)
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
ossim_int32 x
Definition: ossimIpt.h:141
int ossim_int32

◆ initialize()

void ossimWatermarkFilter::initialize ( )
virtual

Initializes state of the object from the input connection.

Reimplemented from ossimImageSourceFilter.

Definition at line 676 of file ossimWatermarkFilter.cpp.

References ossimImageSource::getBoundingRect(), ossimImageSource::getNumberOfOutputBands(), ossimImageSource::getOutputScalarType(), ossimImageSourceFilter::initialize(), theDirtyFlag, theInputBoundingRect, ossimImageSourceFilter::theInputConnection, theInputNumberOfBands, and theInputScalarType.

677 {
678  //---
679  // If state is not already dirty and there is an input connection
680  // check for:
681  //
682  // 1) Scalar change
683  // 2) band number change
684  // 3) bounding box change
685  //
686  // Set state to dirty on a change.
687  //
688  // NOTE: This method intentionally only sets the dirty state and doesn't do
689  // anything else as it is called repetitively during chain setup or chain
690  // state changes.
691  //
692  // The first getTile call will do the real work, call allocate(),
693  // if the state is dirty.
694  //---
695 
696  // Lock for the length of this method.
697  // Set the input connection.
699 
700  // Once dirty flag is set no need to do it again.
701  if (theDirtyFlag == false)
702  {
703  if (theInputConnection)
704  {
705  // Check for scalar type change.
707  {
708  theDirtyFlag = true;
709  return;
710  }
711 
712  // Check for band change.
713  if (theInputNumberOfBands !=
715  {
716  theDirtyFlag = true;
717  return;
718  }
719 
720  // Check for bounding rectangle change.
722  {
723  theDirtyFlag = true;
724  return;
725  }
726  }
727  }
728 }
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossimScalarType theInputScalarType
The input scalar type.
ossim_uint32 theInputNumberOfBands
The number of input bands.
ossimImageSource * theInputConnection
ossimIrect theInputBoundingRect
The bounding rectangle of the input connection.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
bool theDirtyFlag
Set in the initialize method this instructs the getTile that something has changes and it need to cal...

◆ loadState()

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

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

Parameters
kwlKeyword list to initialize from.
prefixUsually something like: "object1."
Returns
This method will alway return true as it is intended to be used in conjuction with the set methods.

Keywords picked up by loadState:

filename: my_colormap_file.jpg

weight: .25

watermark_mode: upper_left

Reimplemented from ossimImageSourceFilter.

Definition at line 908 of file ossimWatermarkFilter.cpp.

References ossimKeywordlist::find(), and ossimImageSourceFilter::loadState().

910 {
911  // Do this first so connections get set up.
912  if (ossimImageSourceFilter::loadState(kwl, prefix) == false)
913  {
914  return false;
915  }
916 
917  const char* lookupReturn;
918 
919  lookupReturn = kwl.find(prefix, WEIGHT_KW);
920  if(lookupReturn)
921  {
922  setWeight(ossimString(lookupReturn).toDouble());
923  }
924 
925  lookupReturn = kwl.find(prefix, WATERMARK_MODE_KW);
926  if(lookupReturn)
927  {
928  setMode(ossimString(lookupReturn));
929  }
930 
931  lookupReturn = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
932  if(lookupReturn)
933  {
934  setFilename(lookupReturn);
935  }
936 
937  if (traceDebug())
938  {
940  << "ossimWatermarkFilter::loadState DEBUG:"
941  << std::endl;
943  }
944 
945  return true;
946 }
virtual std::ostream & print(std::ostream &out) const
Print method.
const char * find(const char *key) const
void setFilename(const ossimFilename &file)
Sets theFilename to file.
void setWeight(ossim_float64 weight)
Sets the weight.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
void setMode(const ossimString &mode)
Sets the filter mode.
static const char * FILENAME_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ openWatermarkFile()

bool ossimWatermarkFilter::openWatermarkFile ( )
protected

Attempts to open "theFilename".

This will load "theWatermark" with the image converting it to the scalar type of the input connection.

Returns
true on success, false if no image handler is found for the image or theInputConnection has not been established.

Definition at line 800 of file ossimWatermarkFilter.cpp.

Referenced by allocate().

801 {
802  if (traceDebug())
803  {
805  << "ossimWatermarkFilter::openWatermarkFile DEBUG: entered..."
806  << std::endl;
807  }
808 
810  {
811  return false;
812  }
813 
814  theWatermark = NULL; // This will destroy any previous tiles.
815 
816  // Open the watermark image.
819  if (!ih)
820  {
821  if (traceDebug())
822  {
824  << "ossimWatermarkFilter::openWatermarkFile"
825  << "\nCould not open: " << theFilename
826  << std::endl;
827  }
828 
829  return false;
830  }
832  {
833  if (traceDebug())
834  {
836  << "ossimWatermarkFilter::openWatermarkFile"
837  << "\nError reading image: " << theFilename
838  << std::endl;
839  return false;
840  }
841  }
842 
843  ih->initialize();
844  ossimRefPtr<ossimImageSource> imageSource = ih.get();
846 
848  {
849  // Remap the watemark to the same scalar type as the input.
850  remapper = new ossimScalarRemapper(imageSource.get(),
853  remapper->initialize();
854  imageSource = remapper.get();
855  }
856 
857  // Get the full image rectangle.
858  theWatermark = imageSource->getTile(ih->getImageRectangle(), 0);
859 
860  // Cleanup...
861  if (remapper.valid())
862  {
863  remapper->disconnect();
864  remapper = NULL;
865  }
866  if(ih.valid())
867  {
868  ih->disconnect();
869  ih = 0;
870  }
871  imageSource = 0;
872 
873  if (theWatermark.valid() == false)
874  {
875  return false;
876  }
877 
878  // Capture the bands as we will need this repetitively.
880 
881  if (traceDebug())
882  {
884  << "ossimWatermarkFilter::openWatermarkFile DEBUG:"
885  << *(theWatermark.get())
886  << endl;
887  }
888 
889  return true;
890 }
virtual ossim_uint32 getNumberOfBands() const
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
Definition: ossimFilename.h:40
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
bool valid() const
Definition: ossimRefPtr.h:75
static const ossimErrorCode OSSIM_ERROR
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
ossimImageSource * theInputConnection
ossim_uint32 theWatermarkNumberOfBands
The number of watermark bands.
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual void initialize()
virtual void initialize()
initialize Does nothing in this class.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual ossimErrorCode getErrorStatus() const
ossimFilename theFilename
File name of watermark image.
static ossimImageHandlerRegistry * instance()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)

◆ print()

std::ostream & ossimWatermarkFilter::print ( std::ostream &  out) const
virtual

Print method.

Called by: friend operator<<

Returns
std::ostream&

Reimplemented from ossimSource.

Definition at line 1154 of file ossimWatermarkFilter.cpp.

References getModeString(), ossimSource::print(), theFilename, and theWatermarkWeight.

1155 {
1156  out << "ossimWatermarkFilter::print"
1157  << "\ntheFilename: " << theFilename
1158  << "\ntheWatermarkWeight: " << theWatermarkWeight
1159  << "\ntheMode: " << getModeString()
1160  << std::endl;
1161  return ossimImageSourceFilter::print(out);
1162 }
ossimString getModeString() const
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
ossimFilename theFilename
File name of watermark image.
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.

◆ saveState()

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

Method to save the state of an object to a keyword list.

Return true if ok or false on error.

Keywords picked saved by saveState

filename: my_colormap_file.jpg

weight: .25

watermark_mode: upper_left

Reimplemented from ossimImageSourceFilter.

Definition at line 892 of file ossimWatermarkFilter.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), ossimKeywordNames::FILENAME_KW, and theFilename.

894 {
895  kwl.add(prefix,
897  theFilename.c_str());
898  kwl.add(prefix,
899  WATERMARK_MODE_KW,
900  getModeString().c_str());
901  kwl.add(prefix,
902  WEIGHT_KW,
904 
905  return ossimImageSourceFilter::saveState(kwl, prefix);
906 }
ossimString getModeString() const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossimFilename theFilename
File name of watermark image.
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
static const char * FILENAME_KW
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.

◆ setFilename()

void ossimWatermarkFilter::setFilename ( const ossimFilename file)

Sets theFilename to file.

Parameters
fileThe watermark image file.

Definition at line 1068 of file ossimWatermarkFilter.cpp.

References theDirtyFlag, theFilename, and theWatermark.

Referenced by setProperty().

1069 {
1070  if (file != theFilename)
1071  {
1072  theFilename = file;
1073  theWatermark = NULL; // Will be reallocated next getTile.
1074  theDirtyFlag = true;
1075  }
1076 
1077  if (traceDebug())
1078  {
1080  << "ossimWatermarkFilter::setFilename DEBUG:" << std::endl;
1082  }
1083 }
virtual std::ostream & print(std::ostream &out) const
Print method.
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
ossimFilename theFilename
File name of watermark image.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool theDirtyFlag
Set in the initialize method this instructs the getTile that something has changes and it need to cal...

◆ setMode()

void ossimWatermarkFilter::setMode ( const ossimString mode)

Sets the filter mode.

Parameters
modeString representing mode.

Definition at line 1085 of file ossimWatermarkFilter.cpp.

References CENTER, ossimString::downcase(), LOWER_CENTER, LOWER_LEFT, LOWER_RIGHT, theMode, UNIFORM_DENSE, UNIFORM_SPARSE, UPPER_CENTER, UPPER_LEFT, and UPPER_RIGHT.

1086 {
1087  ossimString os = mode;
1088  os.downcase();
1089 
1090  if (os == "upper_left")
1091  {
1092  theMode = UPPER_LEFT;
1093  }
1094  else if (os == "upper_center")
1095  {
1097  }
1098  else if (os == "upper_right")
1099  {
1100  theMode = UPPER_RIGHT;
1101  }
1102  else if (os == "center")
1103  {
1104  theMode = CENTER;
1105  }
1106  else if (os == "lower_left")
1107  {
1108  theMode = LOWER_LEFT;
1109  }
1110  else if (os == "lower_center")
1111  {
1113  }
1114  else if (os == "lower_right")
1115  {
1116  theMode = LOWER_RIGHT;
1117  }
1118  else if (os == "uniform_dense")
1119  {
1121  }
1122  else if (os == "uniform_sparse")
1123  {
1125  }
1126  else
1127  {
1128  // Invalid mode...
1129  if (traceDebug())
1130  {
1132  << "ossimWatermarkFilter::setMode DEBUG:"
1133  << "\nInvalid mode! " << mode
1134  << std::endl;
1135  }
1136  }
1137 }
WatermarkMode theMode
The filter mode.
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setProperty()

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

Set property.

Parameters
propertyProperty to set if property->getName() matches a property name of this object.

Reimplemented from ossimImageSourceFilter.

Definition at line 985 of file ossimWatermarkFilter.cpp.

References ossimKeywordNames::FILENAME_KW, and setFilename().

986 {
987  if (!property) return;
988 
989  ossimString os = property->valueToString();
990 
991  ossimString name = property->getName();
992  if (name == ossimKeywordNames::FILENAME_KW)
993  {
994  setFilename(os);
995  }
996  else if (name == WATERMARK_MODE_KW)
997  {
998  setMode(os);
999  }
1000  else if (name == WEIGHT_KW)
1001  {
1002  setWeight(os.toDouble());
1003  }
1004  else
1005  {
1007  }
1008 }
virtual void setProperty(ossimRefPtr< ossimProperty > property)
double toDouble() const
void setFilename(const ossimFilename &file)
Sets theFilename to file.
void setWeight(ossim_float64 weight)
Sets the weight.
void setMode(const ossimString &mode)
Sets the filter mode.
static const char * FILENAME_KW

◆ setWeight()

void ossimWatermarkFilter::setWeight ( ossim_float64  weight)

Sets the weight.

Parameters
weightWeight to use for watermark pixels normalize between 0.0 and 1.0.

Definition at line 1139 of file ossimWatermarkFilter.cpp.

References theWatermarkWeight.

1140 {
1141  if ( (weight >= 0.0) && (weight <= 1.0) )
1142  {
1143  theWatermarkWeight = weight;
1144  }
1145  if (traceDebug())
1146  {
1148  << "ossimWatermarkFilter::setWeight DEBUG:" << std::endl;
1150  }
1151 
1152 }
virtual std::ostream & print(std::ostream &out) const
Print method.
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ theDirtyFlag

bool ossimWatermarkFilter::theDirtyFlag
protected

Set in the initialize method this instructs the getTile that something has changes and it need to call initialize.

Definition at line 340 of file ossimWatermarkFilter.h.

Referenced by allocate(), getTile(), initialize(), and setFilename().

◆ theFilename

ossimFilename ossimWatermarkFilter::theFilename
protected

File name of watermark image.

Definition at line 310 of file ossimWatermarkFilter.h.

Referenced by getProperty(), print(), saveState(), and setFilename().

◆ theInputBoundingRect

ossimIrect ossimWatermarkFilter::theInputBoundingRect
protected

◆ theInputNumberOfBands

ossim_uint32 ossimWatermarkFilter::theInputNumberOfBands
protected

The number of input bands.

Definition at line 331 of file ossimWatermarkFilter.h.

Referenced by allocate(), fill(), and initialize().

◆ theInputScalarType

ossimScalarType ossimWatermarkFilter::theInputScalarType
protected

The input scalar type.

Definition at line 334 of file ossimWatermarkFilter.h.

Referenced by allocate(), and initialize().

◆ theMode

WatermarkMode ossimWatermarkFilter::theMode
protected

The filter mode.

Definition at line 325 of file ossimWatermarkFilter.h.

Referenced by getIntersectingRects(), getMode(), getModeString(), and setMode().

◆ theTile

ossimRefPtr<ossimImageData> ossimWatermarkFilter::theTile
protected

◆ theWatermark

ossimRefPtr<ossimImageData> ossimWatermarkFilter::theWatermark
protected

◆ theWatermarkNumberOfBands

ossim_uint32 ossimWatermarkFilter::theWatermarkNumberOfBands
protected

The number of watermark bands.

Definition at line 322 of file ossimWatermarkFilter.h.

Referenced by fill().

◆ theWatermarkWeight

ossim_float64 ossimWatermarkFilter::theWatermarkWeight
protected

Normalized between 0.0 and 1.0.

Definition at line 313 of file ossimWatermarkFilter.h.

Referenced by fill(), getTile(), print(), and setWeight().


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