iipsrv 0.9.9

Watermark.h

00001 /*
00002     IIPImage Server - Watermark Class
00003 
00004     Enables dynamic watermarking of images with user-defined opacity and
00005     random positioning within the image.
00006 
00007     Development supported by Moravian Library in Brno (Moravska zemska
00008     knihovna v Brne, http://www.mzk.cz/) R&D grant MK00009494301 & Old
00009     Maps Online (http://www.oldmapsonline.org/) from the Ministry of
00010     Culture of the Czech Republic.
00011 
00012 
00013     Copyright (C) 2010 Ruven Pillay.
00014 
00015     This program is free software; you can redistribute it and/or modify
00016     it under the terms of the GNU General Public License as published by
00017     the Free Software Foundation; either version 2 of the License, or
00018     (at your option) any later version.
00019 
00020     This program is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU General Public License for more details.
00024 
00025     You should have received a copy of the GNU General Public License
00026     along with this program; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 */
00029 
00030 
00031 
00032 #ifndef _WATERMARK_H
00033 #define _WATERMARK_H
00034 
00035 #include <string>
00036 
00037 
00038 
00040 
00041 class Watermark {
00042 
00043  private:
00044 
00046   unsigned int _width;
00047 
00049   unsigned int _height;
00050 
00052   unsigned int _channels;
00053 
00055   unsigned int _bpc;
00056 
00058   std::string _image;
00059 
00061   float _opacity;
00062 
00064   float _probability;
00065 
00067   bool _isSet;
00068 
00070   unsigned char* _watermark;
00071 
00072 
00073  public:
00074 
00076   Watermark(){
00077     _isSet=false;
00078     _watermark = NULL;
00079     _opacity = 0;
00080     _probability = 0;
00081   };
00082 
00084 
00088   Watermark( const std::string& file, float opacity, float probability ){
00089     _image = file;
00090     _width = 0;
00091     _height = 0;
00092     _channels = 0;
00093     _bpc = 0;
00094     _opacity = opacity;
00095     _probability = probability;
00096     _isSet = false;
00097     _watermark = NULL;
00098   };
00099 
00101   ~Watermark(){
00102     if( _watermark ) delete[] _watermark;
00103   };
00104 
00106 
00112   void apply( void* data, unsigned int width, unsigned int height, unsigned int channels, unsigned int bpc );
00113 
00115   std::string getImage(){ return _image; };
00116 
00118   float getOpacity(){ return _opacity; };
00119 
00121   float getProbability(){ return _probability; };
00122 
00124   void init();
00125 
00127   bool isSet(){
00128     if( _isSet ) return true;
00129     else return false;
00130   }
00131 
00132 };
00133 
00134 
00135 
00136 #endif