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
View.h
1 /*
2  Image View and Transform Parameters
3 
4  Copyright (C) 2003-2019 Ruven Pillay.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20 
21 
22 #ifndef _VIEW_H
23 #define _VIEW_H
24 
25 
26 #include <cstddef>
27 #include <vector>
28 
29 #include "Transforms.h"
30 
31 
32 
33 
35 
36 class View{
37 
38 
39  private:
40 
41  // Resolution independent x,y,w,h region viewport
42  float view_left, view_top, view_width, view_height;
43 
44  int resolution;
45  unsigned int max_resolutions;
46  unsigned int width, height;
47  unsigned int res_width, res_height;
48  unsigned int min_size;
49  unsigned int max_size;
50  unsigned int requested_width;
51  unsigned int requested_height;
52  float rotation;
53 
54 
57 
60  void calculateResolution( unsigned int m, unsigned int r );
61 
62 
63  public:
64 
65  int xangle;
66  int yangle;
67  bool shaded;
68  int shade[3];
69  bool cmapped;
70  enum cmap_type cmap;
71  bool inverted;
72  int max_layers;
73  int layers;
74  ColourSpaces colourspace;
75  std::vector< std::vector<float> > ctw;
76  int flip;
79  bool embed_icc;
80  CompressionType output_format;
81  float contrast;
82  float gamma;
83  bool equalization;
84 
85 
87  View() {
88  view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0;
89  resolution = 0; max_resolutions = 0;
90  width = 0; height = 0;
91  res_width = 0; res_height = 0;
92  min_size = 1; max_size = 0;
93  requested_width = 0; requested_height = 0;
94  contrast = 1.0; gamma = 1.0;
95  xangle = 0; yangle = 90;
96  shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0;
97  cmapped = false; cmap = HOT; inverted = false;
98  max_layers = 0; layers = 0;
99  rotation = 0.0; flip = 0;
100  maintain_aspect = true;
101  allow_upscaling = true;
102  colourspace = NONE;
103  embed_icc = true;
104  output_format = JPEG;
105  equalization = false;
106  };
107 
108 
110 
111  void setMaxSize( unsigned int m ){ max_size = m; };
112 
113 
115  /* @return maximum output dimension */
116  unsigned int getMaxSize(){ return max_size; };
117 
118 
120 
121  void setAllowUpscaling( bool upscale ){ allow_upscaling = upscale; };
122 
123 
125  /* @return true or false */
126  bool allowUpscaling(){ return allow_upscaling; };
127 
128 
130 
132  void setEmbedICC( bool embed ){ embed_icc = embed; };
133 
134 
136 
138  bool embedICC(){
139  // Disable if colour-mapping, twist, hill-shading or greyscale conversion applied
140  if( cmapped || shaded || ctw.size() || colourspace==GREYSCALE ) return false;
141  return embed_icc;
142  };
143 
144 
146 
147  void setMaxResolutions( unsigned int r ){ max_resolutions = r; resolution=r-1; };
148 
149 
151  /* @return requested width */
152  unsigned int getRequestWidth();
153 
154 
156 
157  void setRequestWidth( unsigned int w ){
158  requested_width = w;
159  };
160 
161 
163  /* @return requested height */
164  unsigned int getRequestHeight();
165 
166 
168 
169  void setRequestHeight( unsigned int h ){
170  requested_height = h;
171  };
172 
173 
175  /* @return requested resolution level */
176  unsigned int getResolution();
177 
178 
180  /* @return scaling factor */
181  float getScale();
182 
183 
185 
186  void setViewLeft( float x );
187 
188 
190 
191  void setViewTop( float y );
192 
193 
195 
196  void setViewWidth( float w );
197 
198 
200 
201  void setViewHeight( float h );
202 
203 
205 
208  void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; };
209 
210 
212 
213  void setMaxLayers( int l ){ max_layers = l; };
214 
216 
217  void setLayers( int l ){ layers = l; };
218 
220  int getLayers();
221 
223  /* @return image width */
224  unsigned int getImageWidth(){ return width; };
225 
227  /* @return image height */
228  unsigned int getImageHeight(){ return height; };
229 
231  /* @return position of left of viewport in pixels */
232  unsigned int getViewLeft() ;
233 
235  /* @return position of top of viewport in pixels */
236  unsigned int getViewTop();
237 
239  /* @return width of viewport in pixels */
240  unsigned int getViewWidth();
241 
243  /* @return height of viewport in pixels */
244  unsigned int getViewHeight();
245 
247  /* @return boolean indicating whether viewport specified */
248  bool viewPortSet();
249 
251 
252  void setRotation( float r ){ rotation = r; };
253 
255  /* @return requested rotation angle in degrees */
256  float getRotation(){ return rotation; };
257 
260  if( contrast != 1.0 || gamma != 1.0 || cmapped || shaded || inverted || ctw.size() ){
261  return true;
262  }
263  else return false;
264  }
265 
268  if( equalization || colourspace==BINARY || contrast==-1 ) return true;
269  else return false;
270  }
271 
272 };
273 
274 
275 #endif
View::contrast
float contrast
Requested output format.
Definition: View.h:81
View::maintain_aspect
bool maintain_aspect
Flip (1=horizontal, 2=vertical)
Definition: View.h:77
View::getScale
float getScale()
Return the scaling required in case our requested width or height is in between available resolutions...
View::View
View()
Whether to perform histogram equalization.
Definition: View.h:87
View::getImageHeight
unsigned int getImageHeight()
Return the image height at our requested resolution.
Definition: View.h:228
View::yangle
int yangle
Horizontal View.
Definition: View.h:66
View::viewPortSet
bool viewPortSet()
Indicate whether the viewport has been set.
View::getResolution
unsigned int getResolution()
Return the requested resolution.
View::getViewLeft
unsigned int getViewLeft()
Return the left pixel of the viewport.
View::cmapped
bool cmapped
Shading incident light angles (x,y,z)
Definition: View.h:69
View::colourspace
ColourSpaces colourspace
Number of quality layers.
Definition: View.h:74
View::getMaxSize
unsigned int getMaxSize()
Get the maximum allowed output size.
Definition: View.h:116
View::getViewHeight
unsigned int getViewHeight()
Return the pixel height of the viewport.
View::setMaxSize
void setMaxSize(unsigned int m)
Set the maximum view port dimension.
Definition: View.h:111
View
Class to intelligently handle Image Transforms.
Definition: View.h:36
View::output_format
CompressionType output_format
Indicate whether we should embed ICC profiles.
Definition: View.h:80
View::setAllowUpscaling
void setAllowUpscaling(bool upscale)
Set the allow_upscaling flag.
Definition: View.h:121
View::setMaxLayers
void setMaxLayers(int l)
Limit the maximum number of quality layers we are allowed to decode.
Definition: View.h:213
View::setRequestWidth
void setRequestWidth(unsigned int w)
Set the size of the requested width.
Definition: View.h:157
View::setRotation
void setRotation(float r)
Set rotation.
Definition: View.h:252
View::layers
int layers
Maximum number of quality layers allowed.
Definition: View.h:73
View::getRequestWidth
unsigned int getRequestWidth()
Get the size of the requested width.
View::floatProcessing
bool floatProcessing()
Whether view requires floating point processing.
Definition: View.h:259
View::getImageWidth
unsigned int getImageWidth()
Return the image width at our requested resolution.
Definition: View.h:224
View::getRequestHeight
unsigned int getRequestHeight()
Get the size of the requested height.
View::setMaxResolutions
void setMaxResolutions(unsigned int r)
Set the maximum view port dimension.
Definition: View.h:147
View::max_layers
int max_layers
Whether to invert colormap.
Definition: View.h:72
View::requireHistogram
bool requireHistogram()
Whether we require a histogram.
Definition: View.h:267
View::setViewTop
void setViewTop(float y)
Set the top co-ordinate of the viewport.
View::setImageSize
void setImageSize(unsigned int w, unsigned int h)
Set the source image pixel size.
Definition: View.h:208
View::setRequestHeight
void setRequestHeight(unsigned int h)
Set the size of the requested height.
Definition: View.h:169
View::shaded
bool shaded
Vertical View.
Definition: View.h:67
View::allowUpscaling
bool allowUpscaling()
Get the allow_upscaling flag.
Definition: View.h:126
View::allow_upscaling
bool allow_upscaling
Indicate whether aspect ratio should be maintained.
Definition: View.h:78
View::getViewTop
unsigned int getViewTop()
Return the top pixel of the viewport.
View::embedICC
bool embedICC()
Get the embed_icc flag - disable in case of certain types of processing.
Definition: View.h:138
View::shade
int shade[3]
Whether to use shading view.
Definition: View.h:68
View::equalization
bool equalization
Gamma adjustment requested by GAM command.
Definition: View.h:83
View::embed_icc
bool embed_icc
Indicate whether images may be served larger than the source file.
Definition: View.h:79
View::setViewHeight
void setViewHeight(float h)
Set the height co-ordinate of the viewport.
View::setEmbedICC
void setEmbedICC(bool embed)
Set the embed_icc flag.
Definition: View.h:132
View::setViewLeft
void setViewLeft(float x)
Set the left co-ordinate of the viewport.
View::ctw
std::vector< std::vector< float > > ctw
Requested colourspace.
Definition: View.h:75
View::gamma
float gamma
Contrast adjustment requested by CNT command.
Definition: View.h:82
View::getLayers
int getLayers()
Return the number of layers to decode.
View::getRotation
float getRotation()
Get rotation.
Definition: View.h:256
View::cmap
enum cmap_type cmap
Whether to modify colormap.
Definition: View.h:70
View::flip
int flip
Colour twist matrix.
Definition: View.h:76
View::setLayers
void setLayers(int l)
Set the number of quality layers to decode, limiting to our max value.
Definition: View.h:217
View::getViewWidth
unsigned int getViewWidth()
Return the pixel width of the viewport.
View::inverted
bool inverted
colormap
Definition: View.h:71
View::setViewWidth
void setViewWidth(float w)
Set the width co-ordinate of the viewport.