iipsrv 0.9.9

IIPImage.h

00001 // IIPImage class
00002 
00003 /*  IIP fcgi server module
00004 
00005     Copyright (C) 2000-2011 Ruven Pillay.
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 
00023 #ifndef _IIPIMAGE_H
00024 #define _IIPIMAGE_H
00025 
00026 
00027 // Fix missing snprintf in Windows
00028 #if _MSC_VER
00029 #define snprintf _snprintf
00030 #endif
00031 
00032 
00033 #include <string>
00034 #include <list>
00035 #include <vector>
00036 #include <map>
00037 
00038 #include "RawTile.h"
00039 
00040 
00041 
00043 
00048 class IIPImage {
00049 
00050  private:
00051 
00053   std::string imagePath; 
00054 
00056   std::string fileSystemPrefix;
00057 
00059   std::string fileNamePattern;
00060 
00062   bool isFile;
00063 
00065   void testImageType();
00066 
00068   void measureHorizontalAngles();
00069 
00071   void measureVerticalAngles();
00072 
00074   std::list <int> horizontalAnglesList;
00075 
00077   std::list <int> verticalAnglesList;
00078 
00079 
00080 
00081   //protected: 
00082   public:
00083 
00085   std::string type;
00086 
00088   std::vector<unsigned int> image_widths, image_heights;
00089 
00091   unsigned int tile_width, tile_height;
00092 
00094   ColourSpaces colourspace;
00095 
00097   unsigned int numResolutions;
00098 
00100   unsigned int bpp;
00101 
00103   unsigned int channels;
00104 
00106   bool isSet;
00107 
00109   int currentX, currentY;
00110 
00112   std::map <const std::string, std::string> metadata;
00113 
00115   time_t timestamp;
00116 
00117 
00118  public:
00119 
00121   IIPImage();
00122 
00124   IIPImage( const std::string& );
00125 
00127   IIPImage( const IIPImage& );
00128 
00130   virtual ~IIPImage() { ; };
00131 
00133   void Initialise();
00134 
00136   std::list <int> getVerticalViewsList(){ return verticalAnglesList; };
00137 
00139   std::list <int> getHorizontalViewsList(){ return horizontalAnglesList; };
00140 
00142   const std::string& getImagePath() { return imagePath; };
00143 
00145 
00148   const std::string getFileName( int x, int y );
00149 
00151   const std::string& getImageType() { return type; };
00152 
00154   void updateTimestamp( const std::string& );
00155 
00157   const std::string getTimestamp();
00158 
00160   bool set() { return isSet; };
00161 
00163   void setFileSystemPrefix( const std::string& prefix ) { fileSystemPrefix = prefix; };
00164 
00166   void setFileNamePattern( const std::string& pattern ) { fileNamePattern = pattern; };
00167 
00169   int getNumResolutions() { return numResolutions; };
00170 
00172   unsigned int getNumBitsPerPixel() { return bpp; };
00173 
00175   unsigned int getNumChannels() { return channels; };
00176 
00178 
00180   unsigned int getImageWidth( int n=0) { return image_widths[n]; };
00181 
00183 
00185   unsigned int getImageHeight( int n=0 ) { return image_heights[n]; };
00186 
00188 
00189   unsigned int getTileHeight() { return tile_height; };
00190 
00192   unsigned int getTileWidth() { return tile_width; };
00193 
00195   ColourSpaces getColourSpace() { return colourspace; };
00196 
00198 
00199   std::string getMetadata( const std::string& index ) {
00200     return metadata[index];
00201   };
00202 
00203 
00204 
00206 
00209   virtual void Load( const std::string& module ) {;};
00210 
00212   virtual const std::string getDescription() { return std::string( "IIPImage Base Class" ); };
00213 
00215   virtual void openImage() { throw std::string( "IIPImage openImage called" ); };
00216 
00218 
00221   virtual void loadImageInfo( int x, int y ) { ; };
00222 
00224   virtual void closeImage() {;};
00225 
00226 
00228 
00235   virtual RawTile getTile( int h, int v, unsigned int r, int l, unsigned int t ) { return RawTile(); };
00236 
00237 
00239 
00250     virtual void getRegion( int ha, int va, unsigned int r, int layers, int x, int y, unsigned int w, unsigned int h, unsigned char* b ){ return; };
00251 
00253   const IIPImage& operator = ( const IIPImage& );
00254 
00256   friend int operator == ( const IIPImage&, const IIPImage& );
00257 
00259   friend int operator != ( const IIPImage&, const IIPImage& );
00260 
00261 
00262 };
00263 
00264 
00265 
00266 #endif