Watermark.h
/*
IIPImage Server - Watermark Class
Enables dynamic watermarking of images with user-defined opacity and
random positioning within the image.
Development supported by Moravian Library in Brno (Moravska zemska
knihovna v Brne, http://www.mzk.cz/) R&D grant MK00009494301 & Old
Maps Online (http://www.oldmapsonline.org/) from the Ministry of
Culture of the Czech Republic.
Copyright (C) 2010-2013 Ruven Pillay.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _WATERMARK_H
#define _WATERMARK_H
#include <string>
class Watermark {
private:
unsigned int _width;
unsigned int _height;
unsigned int _channels;
unsigned int _bpc;
std::string _image;
float _opacity;
float _probability;
bool _isSet;
unsigned char* _watermark;
public:
Watermark(){
_isSet=false;
_watermark = NULL;
_opacity = 0.0;
_probability = 0.0;
};
Watermark( const std::string& file, float opacity, float probability ){
_image = file;
_width = 0;
_height = 0;
_channels = 0;
_bpc = 0;
_opacity = opacity;
_probability = probability;
_isSet = false;
_watermark = NULL;
};
~Watermark(){
if( _watermark ) delete[] _watermark;
};
void apply( void* data, unsigned int width, unsigned int height, unsigned int channels, unsigned int bpc );
std::string getImage(){ return _image; };
float getOpacity(){ return _opacity; };
float getProbability(){ return _probability; };
void init();
bool isSet(){
if( _isSet ) return true;
else return false;
}
};
#endif
Watermark::Watermark
Watermark()
Constructor.
Definition Watermark.h:76
Watermark::apply
void apply(void *data, unsigned int width, unsigned int height, unsigned int channels, unsigned int bpc)
Apply the watermark to a data buffer.
Watermark::getOpacity
float getOpacity()
Return watermark opacity.
Definition Watermark.h:118
Watermark::~Watermark
~Watermark()
Destructor.
Definition Watermark.h:101
Watermark::getProbability
float getProbability()
Return watermark probability.
Definition Watermark.h:121
Watermark::Watermark
Watermark(const std::string &file, float opacity, float probability)
Constructor.
Definition Watermark.h:88
Watermark::isSet
bool isSet()
Determine whether a watermark has been specified.
Definition Watermark.h:127
Watermark::getImage
std::string getImage()
Return watermark image path.
Definition Watermark.h:115
Watermark::init
void init()
Initialize our watermark image.