iipsrv  0.9.9
IIPImage.h
1 // IIPImage class
2 
3 /* IIP fcgi server module
4 
5  Copyright (C) 2000-2011 Ruven Pillay.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 
23 #ifndef _IIPIMAGE_H
24 #define _IIPIMAGE_H
25 
26 
27 // Fix missing snprintf in Windows
28 #if _MSC_VER
29 #define snprintf _snprintf
30 #endif
31 
32 
33 #include <string>
34 #include <list>
35 #include <vector>
36 #include <map>
37 
38 #include "RawTile.h"
39 
40 
41 
43 
48 class IIPImage {
49 
50  private:
51 
53  std::string imagePath;
54 
56  std::string fileSystemPrefix;
57 
59  std::string fileNamePattern;
60 
62  bool isFile;
63 
65  void testImageType();
66 
68  void measureHorizontalAngles();
69 
71  void measureVerticalAngles();
72 
74  std::list <int> horizontalAnglesList;
75 
77  std::list <int> verticalAnglesList;
78 
79 
80 
81  //protected:
82  public:
83 
85  std::string type;
86 
88  std::vector<unsigned int> image_widths, image_heights;
89 
91  unsigned int tile_width, tile_height;
92 
94  ColourSpaces colourspace;
95 
97  unsigned int numResolutions;
98 
100  unsigned int bpp;
101 
103  unsigned int channels;
104 
106  bool isSet;
107 
109  int currentX, currentY;
110 
112  std::map <const std::string, std::string> metadata;
113 
115  time_t timestamp;
116 
117 
118  public:
119 
121  IIPImage();
122 
124  IIPImage( const std::string& );
125 
127  IIPImage( const IIPImage& );
128 
130  virtual ~IIPImage() { ; };
131 
133  void Initialise();
134 
136  std::list <int> getVerticalViewsList(){ return verticalAnglesList; };
137 
139  std::list <int> getHorizontalViewsList(){ return horizontalAnglesList; };
140 
142  const std::string& getImagePath() { return imagePath; };
143 
145 
148  const std::string getFileName( int x, int y );
149 
151  const std::string& getImageType() { return type; };
152 
154  void updateTimestamp( const std::string& );
155 
157  const std::string getTimestamp();
158 
160  bool set() { return isSet; };
161 
163  void setFileSystemPrefix( const std::string& prefix ) { fileSystemPrefix = prefix; };
164 
166  void setFileNamePattern( const std::string& pattern ) { fileNamePattern = pattern; };
167 
170 
172  unsigned int getNumBitsPerPixel() { return bpp; };
173 
175  unsigned int getNumChannels() { return channels; };
176 
178 
180  unsigned int getImageWidth( int n=0) { return image_widths[n]; };
181 
183 
185  unsigned int getImageHeight( int n=0 ) { return image_heights[n]; };
186 
188 
189  unsigned int getTileHeight() { return tile_height; };
190 
192  unsigned int getTileWidth() { return tile_width; };
193 
195  ColourSpaces getColourSpace() { return colourspace; };
196 
198 
199  std::string getMetadata( const std::string& index ) {
200  return metadata[index];
201  };
202 
203 
204 
206 
209  virtual void Load( const std::string& module ) {;};
210 
212  virtual const std::string getDescription() { return std::string( "IIPImage Base Class" ); };
213 
215  virtual void openImage() { throw std::string( "IIPImage openImage called" ); };
216 
218 
221  virtual void loadImageInfo( int x, int y ) { ; };
222 
224  virtual void closeImage() {;};
225 
226 
228 
235  virtual RawTile getTile( int h, int v, unsigned int r, int l, unsigned int t ) { return RawTile(); };
236 
237 
239 
250  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; };
251 
253  const IIPImage& operator = ( const IIPImage& );
254 
256  friend int operator == ( const IIPImage&, const IIPImage& );
257 
259  friend int operator != ( const IIPImage&, const IIPImage& );
260 
261 
262 };
263 
264 
265 
266 #endif
friend int operator!=(const IIPImage &, const IIPImage &)
Comparison non-equality operator.
unsigned int getNumBitsPerPixel()
Return the number of bits per pixel for this image.
Definition: IIPImage.h:172
unsigned int getTileWidth()
Return the base tile width in pixels.
Definition: IIPImage.h:192
unsigned int getImageWidth(int n=0)
Return the image width in pixels for a given resolution.
Definition: IIPImage.h:180
void updateTimestamp(const std::string &)
Get the image timestamp.
time_t timestamp
Image modification timestamp.
Definition: IIPImage.h:115
std::map< const std::string, std::string > metadata
STL map to hold string metadata.
Definition: IIPImage.h:112
void Initialise()
Test the image and initialise some parameters.
unsigned int getNumChannels()
Return the number of channels for this image.
Definition: IIPImage.h:175
unsigned int numResolutions
The number of available resolutions in this image.
Definition: IIPImage.h:97
virtual RawTile getTile(int h, int v, unsigned int r, int l, unsigned int t)
Return an individual tile for a given angle and resolution.
Definition: IIPImage.h:235
std::string type
Return the image type e.g. tif.
Definition: IIPImage.h:85
IIPImage()
Default Constructor.
unsigned int getTileHeight()
Return the base tile height in pixels for a given resolution.
Definition: IIPImage.h:189
const std::string & getImagePath()
Return the image path.
Definition: IIPImage.h:142
virtual const std::string getDescription()
Return codec description: Overloaded by child class.
Definition: IIPImage.h:212
friend int operator==(const IIPImage &, const IIPImage &)
Comparison equality operator.
std::list< int > getHorizontalViewsList()
Return a list of horizontal angles.
Definition: IIPImage.h:139
unsigned int bpp
The bits per pixel for this image.
Definition: IIPImage.h:100
unsigned int getImageHeight(int n=0)
Return the image height in pixels for a given resolution.
Definition: IIPImage.h:185
virtual void openImage()
Open the image: Overloaded by child class.
Definition: IIPImage.h:215
const std::string getTimestamp()
Get a HTTP RFC 1123 formatted timestamp.
const IIPImage & operator=(const IIPImage &)
Assignment operator.
std::string getMetadata(const std::string &index)
Return image metadata.
Definition: IIPImage.h:199
std::list< int > getVerticalViewsList()
Return a list of available vertical angles.
Definition: IIPImage.h:136
int getNumResolutions()
Return the number of available resolutions in the image.
Definition: IIPImage.h:169
Main class to handle the pyramidal image source.
Definition: IIPImage.h:48
unsigned int tile_width
The base tile pixel dimensions.
Definition: IIPImage.h:91
virtual void loadImageInfo(int x, int y)
Load information about the image eg. number of channels, tile size etc.
Definition: IIPImage.h:221
void setFileSystemPrefix(const std::string &prefix)
Set a file system prefix for added security.
Definition: IIPImage.h:163
bool isSet
Indicate whether we have opened and initialised some paramters for this image.
Definition: IIPImage.h:106
ColourSpaces colourspace
The colour space of the image.
Definition: IIPImage.h:94
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 a region for a given angle and resolution.
Definition: IIPImage.h:250
const std::string getFileName(int x, int y)
Return the full file path for a particular horizontal and vertical angle.
unsigned int channels
The number of channels for this image.
Definition: IIPImage.h:103
virtual void closeImage()
Close the image: Overloaded by child class.
Definition: IIPImage.h:224
int currentX
If we have an image sequence, the current X and Y position.
Definition: IIPImage.h:109
const std::string & getImageType()
Get the image type.
Definition: IIPImage.h:151
Class to represent a single image tile.
Definition: RawTile.h:43
void setFileNamePattern(const std::string &pattern)
Set the file name pattern used in image sequences.
Definition: IIPImage.h:166
ColourSpaces getColourSpace()
Return the colour space for this image.
Definition: IIPImage.h:195
virtual void Load(const std::string &module)
Load the appropriate codec module for this image type.
Definition: IIPImage.h:209
virtual ~IIPImage()
Virtual Destructor.
Definition: IIPImage.h:130
std::vector< unsigned int > image_widths
The image pixel dimensions.
Definition: IIPImage.h:88