36 static const char WATERMARK_MODE_KW[] =
"watermark_mode";
37 static const char WEIGHT_KW[] =
"weight";
39 #ifdef OSSIM_ID_ENABLED 40 static const char OSSIM_ID[] =
"$Id: ossimWatermarkFilter.cpp 15766 2009-10-20 12:37:09Z gpotts $";
52 theInputBoundingRect(),
60 <<
"ossimPixelFlipper::ossimPixelFlipper" << std::endl;
61 #ifdef OSSIM_ID_ENABLED 63 <<
"OSSIM_ID: " << OSSIM_ID << std::endl;
82 return ossimString(
"Watermark Filter - Applies watermark image onto getTile Request.");
90 description +=
"Valid modes:\n";
92 vector<ossimString> list;
95 vector<ossimString>::const_iterator i = list.begin();
96 while (i != list.end())
152 if (inputTile.
valid() &&
218 <<
" Not supported by ossimWatermarkFilter" << std::endl;
235 vector<ossimIrect> rects(0);
238 if (rects.size() == 0)
274 vector<ossimIrect>::const_iterator i = rects.begin();
275 while (i != rects.end())
277 if ( (*i).intersects(CLIPPED_TILE_RECT) )
291 (CLIPPED_WATERMARRK_RECT.
ul().
y - (*i).ul().y) * wmWidth +
292 CLIPPED_WATERMARRK_RECT.
ul().
x - (*i).ul().x;
294 (CLIPPED_WATERMARRK_RECT.
ul().
y - TILE_RECT.
ul().
y)* otWidth +
295 CLIPPED_WATERMARRK_RECT.
ul().
x - TILE_RECT.
ul().
x;
298 for (
ossim_int32 line = 0; line < clipHeight; ++line)
301 for (
ossim_int32 sample = 0; sample < clipWidth; ++sample)
312 if (wmBuf[wmBand][wmOffset+sample] != wmNull[wmBand])
316 (otBuf[otBand][otOffset+sample] != otNull[otBand]) ?
317 otBuf[otBand][otOffset+sample] * inputPixWeight :
328 otBuf[otBand][otOffset+sample] =
static_cast<T
>(
329 ( (p3 >= otMin[otBand]) ?
330 (p3 < otMax[otBand] ? p3 : otMax[otBand]) :
424 if (inputWidth > watermarkWidth)
427 static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
428 origin.
x = origin.
x + offset;
452 if (inputWidth > watermarkWidth)
455 static_cast<ossim_int32>(inputWidth - watermarkWidth);
456 origin.
x = origin.
x + offset;
480 if (inputWidth > watermarkWidth)
483 static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
484 origin.
x = origin.
x + offset;
487 if (inputHeight > watermarkHeight)
490 static_cast<ossim_int32>((inputHeight - watermarkHeight) / 2);
491 origin.
y = origin.
y + offset;
513 if (inputHeight > watermarkHeight)
516 static_cast<ossim_int32>(inputHeight - watermarkHeight);
517 origin.
y = origin.
y + offset;
541 if (inputWidth > watermarkWidth)
544 static_cast<ossim_int32>((inputWidth - watermarkWidth) / 2);
545 origin.
x = origin.
x + offset;
548 if (inputHeight > watermarkHeight)
551 static_cast<ossim_int32>(inputHeight - watermarkHeight);
552 origin.
y = origin.
y + offset;
575 if (inputWidth > watermarkWidth)
578 static_cast<ossim_int32>(inputWidth - watermarkWidth);
579 origin.
x = origin.
x + offset;
582 if (inputHeight > watermarkHeight)
585 static_cast<ossim_int32>(inputHeight - watermarkHeight);
586 origin.
y = origin.
y + offset;
608 ossim_uint32 watermarksHigh = inputHeight / watermarkHeight;
609 if (inputHeight % watermarkHeight) ++watermarksHigh;
611 ossim_uint32 watermarksWide = inputWidth / watermarkWidth;
612 if (inputWidth % watermarkWidth) ++watermarksWide;
629 origin.
x = origin.
x + xOffset;
631 origin.
y = origin.
y + yOffset;
648 ossim_uint32 watermarksHigh = inputHeight/(watermarkHeight+gapHeight);
649 if (inputHeight % watermarkHeight) ++watermarksHigh;
651 ossim_uint32 watermarksWide = inputWidth/(watermarkWidth+gapWidth);
652 if (inputWidth % watermarkWidth) ++watermarksWide;
669 origin.
x = origin.
x + xOffset;
671 origin.
y = origin.
y + yOffset;
805 <<
"ossimWatermarkFilter::openWatermarkFile DEBUG: entered..." 824 <<
"ossimWatermarkFilter::openWatermarkFile" 836 <<
"ossimWatermarkFilter::openWatermarkFile" 854 imageSource = remapper.
get();
861 if (remapper.
valid())
884 <<
"ossimWatermarkFilter::openWatermarkFile DEBUG:" 893 const char* prefix)
const 917 const char* lookupReturn;
919 lookupReturn = kwl.
find(prefix, WEIGHT_KW);
925 lookupReturn = kwl.
find(prefix, WATERMARK_MODE_KW);
940 <<
"ossimWatermarkFilter::loadState DEBUG:" 960 else if (name == WATERMARK_MODE_KW)
962 vector<ossimString> constraintList;
973 else if (name == WEIGHT_KW)
987 if (!property)
return;
996 else if (name == WATERMARK_MODE_KW)
1000 else if (name == WEIGHT_KW)
1011 std::vector<ossimString>& propertyNames)
const 1014 propertyNames.push_back(WATERMARK_MODE_KW);
1015 propertyNames.push_back(WEIGHT_KW);
1080 <<
"ossimWatermarkFilter::setFilename DEBUG:" << std::endl;
1090 if (os ==
"upper_left")
1094 else if (os ==
"upper_center")
1098 else if (os ==
"upper_right")
1102 else if (os ==
"center")
1106 else if (os ==
"lower_left")
1110 else if (os ==
"lower_center")
1114 else if (os ==
"lower_right")
1118 else if (os ==
"uniform_dense")
1122 else if (os ==
"uniform_sparse")
1132 <<
"ossimWatermarkFilter::setMode DEBUG:" 1133 <<
"\nInvalid mode! " << mode
1141 if ( (weight >= 0.0) && (weight <= 1.0) )
1148 <<
"ossimWatermarkFilter::setWeight DEBUG:" << std::endl;
1156 out <<
"ossimWatermarkFilter::print" 16 bit unsigned integer (15 bits used)
virtual std::ostream & print(std::ostream &out) const
Print method.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of the object from a keyword list.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set property.
virtual ossim_uint32 getWidth() const
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual const ossim_float64 * getMaxPix() const
void getUpperRightRect(vector< ossimIrect > &rects)
Addes upper right watermark rectangle to rects if it intersects theTile rect clipped to input boundin...
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
static const ossimFilename NIL
This was taken from Wx widgets for performing touch and access date stamps.
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
ossimString getModeString() const
virtual void disconnect(ossimConnectableObject *object=0)
Will disconnect the object passed in.
Represents serializable keyword/value map.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
const char * find(const char *key) const
void getModeList(vector< ossimString > &list) const
virtual ~ossimWatermarkFilter()
destructor
virtual ossimString getLongName() const
bool openWatermarkFile()
Attempts to open "theFilename".
ossim_uint32 height() const
void getUniformSparceRects(vector< ossimIrect > &rects)
Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect...
static ossimString toString(bool aValue)
Numeric to string methods.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this objects properties to the list.
ossimScalarType theInputScalarType
The input scalar type.
const ossimIpt & ul() const
virtual ossimDataObjectStatus getDataObjectStatus() const
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
16 bit unsigned integer (13 bits used)
bool intersects(const ossimIrect &rect) const
unsigned short ossim_uint16
virtual void initialize()
Initialize the data buffer.
void getUpperCenterRect(vector< ossimIrect > &rects)
Addes upper center watermark rectangle to rects if it intersects theTile rect clipped to input boundi...
virtual void initialize()
WatermarkMode theMode
The filter mode.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
static ossimImageDataFactory * instance()
ossim_uint32 theInputNumberOfBands
The number of input bands.
virtual ossimString getShortName() const
virtual ossimDataObjectStatus validate() const
signed short ossim_sint16
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
ossimRefPtr< ossimImageData > theWatermark
Tile storage for watermark image.
void getIntersectingRects(vector< ossimIrect > &rects)
Computes the bounding rectangles.
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
void setFilename(const ossimFilename &file)
Sets theFilename to file.
virtual ossimIrect getImageRectangle() const
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.
ossim_uint32 theWatermarkNumberOfBands
The number of watermark bands.
static ossimString downcase(const ossimString &aString)
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
const ossim_float64 DEFAULT_WEIGHT
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
void getLowerLeftRect(vector< ossimIrect > &rects)
Addes lower left watermark rectangle to rects if it intersects theTile rect clipped to input bounding...
ossimIrect clipToRect(const ossimIrect &rect) const
ossimRefPtr< ossimImageData > theTile
The returned tile.
void setMode(const ossimString &mode)
Sets the filter mode.
void fill(T dummy)
Writes watermark(s) to theTile.
void getUniformDenseRects(vector< ossimIrect > &rects)
Addes rectangles to rects if it intersects theTile rect clipped to input bounding rect...
virtual void initialize()
virtual void setOrigin(const ossimIpt &origin)
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual const ossim_float64 * getMinPix() const
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.
class ossimWatermarkFilter Applies an image or watermark to image.
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
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossimWatermarkFilter::WatermarkMode getMode() const
void setIoType(ossimFilenamePropertyIoType ioType)
virtual const void * getBuf() const
ossimFilename theFilename
File name of watermark image.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual ossimString getDescription() const
virtual void initialize()
Initializes state of the object from the input connection.
ossimWatermarkFilter()
contructor
static ossimImageHandlerRegistry * instance()
#define RTTI_DEF1(cls, name, b1)
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...
static const char * FILENAME_KW
ossim_float64 theWatermarkWeight
Normalized between 0.0 and 1.0.
void getUpperLeftRect(vector< ossimIrect > &rects)
Addes upper left watermark rectangle to rects if it intersects theTile rect clipped to input bounding...
unsigned char ossim_uint8
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
bool allocate()
Allocates / recomputes things that are needed.
std::basic_ostream< char > ostream
Base class for char output streams.
void setCacheRefreshBit()
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 ossimIrect &tile_rect, ossim_uint32 resLevel=0)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)