iipsrv  1.1
iipsrv is an advanced high-performance feature-rich image server for web-based streamed viewing and zooming of ultra high-resolution images
Watermark.h
1 /*
2  IIPImage Server - Watermark Class
3 
4  Enables dynamic watermarking of images with user-defined opacity and
5  random positioning within the image.
6 
7  Development supported by Moravian Library in Brno (Moravska zemska
8  knihovna v Brne, http://www.mzk.cz/) R&D grant MK00009494301 & Old
9  Maps Online (http://www.oldmapsonline.org/) from the Ministry of
10  Culture of the Czech Republic.
11 
12 
13  Copyright (C) 2010-2013 Ruven Pillay.
14 
15  This program is free software; you can redistribute it and/or modify
16  it under the terms of the GNU General Public License as published by
17  the Free Software Foundation; either version 3 of the License, or
18  (at your option) any later version.
19 
20  This program is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with this program; if not, write to the Free Software Foundation,
27  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 
31 
32 #ifndef _WATERMARK_H
33 #define _WATERMARK_H
34 
35 #include <string>
36 
37 
38 
40 
41 class Watermark {
42 
43  private:
44 
46  unsigned int _width;
47 
49  unsigned int _height;
50 
52  unsigned int _channels;
53 
55  unsigned int _bpc;
56 
58  std::string _image;
59 
61  float _opacity;
62 
64  float _probability;
65 
67  bool _isSet;
68 
70  unsigned char* _watermark;
71 
72 
73  public:
74 
77  _isSet=false;
78  _watermark = NULL;
79  _opacity = 0.0;
80  _probability = 0.0;
81  };
82 
84 
88  Watermark( const std::string& file, float opacity, float probability ){
89  _image = file;
90  _width = 0;
91  _height = 0;
92  _channels = 0;
93  _bpc = 0;
94  _opacity = opacity;
95  _probability = probability;
96  _isSet = false;
97  _watermark = NULL;
98  };
99 
102  if( _watermark ) delete[] _watermark;
103  };
104 
106 
112  void apply( void* data, unsigned int width, unsigned int height, unsigned int channels, unsigned int bpc );
113 
115  std::string getImage(){ return _image; };
116 
118  float getOpacity(){ return _opacity; };
119 
121  float getProbability(){ return _probability; };
122 
124  void init();
125 
127  bool isSet(){
128  if( _isSet ) return true;
129  else return false;
130  }
131 
132 };
133 
134 
135 
136 #endif
void init()
Initialize our watermark image.
float getProbability()
Return watermark probability.
Definition: Watermark.h:121
bool isSet()
Determine whether a watermark has been specified.
Definition: Watermark.h:127
Watermark()
Constructor.
Definition: Watermark.h:76
std::string getImage()
Return watermark image path.
Definition: Watermark.h:115
float getOpacity()
Return watermark opacity.
Definition: Watermark.h:118
Watermark class.
Definition: Watermark.h:41
void apply(void *data, unsigned int width, unsigned int height, unsigned int channels, unsigned int bpc)
Apply the watermark to a data buffer.
~Watermark()
Destructor.
Definition: Watermark.h:101
Watermark(const std::string &file, float opacity, float probability)
Constructor.
Definition: Watermark.h:88