iipsrv  1.0
View.h
1 /*
2  Image View and Transform Parameters
3 
4  Copyright (C) 2003-2016 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 //include round function for MSVC compiler
32 #if _MSC_VER
33 #include "../windows/Time.h"
34 #endif
35 
36 
37 
38 
40 
41 class View{
42 
43 
44  private:
45 
46  // Resolution independent x,y,w,h region viewport
47  float view_left, view_top, view_width, view_height;
48 
49  int resolution;
50  unsigned int max_resolutions;
51  unsigned int width, height;
52  unsigned int res_width, res_height;
53  unsigned int min_size;
54  unsigned int max_size;
55  unsigned int requested_width;
56  unsigned int requested_height;
57  float contrast;
58  float gamma;
59  float rotation;
60 
61 
64 
67  void calculateResolution( unsigned int m, unsigned int r );
68 
69 
70  public:
71 
72  int xangle;
73  int yangle;
74  bool shaded;
75  int shade[3];
76  bool cmapped;
77  enum cmap_type cmap;
78  bool inverted;
79  int max_layers;
80  int layers;
81  ColourSpaces colourspace;
82  std::vector< std::vector<float> > ctw;
83  int flip;
85 
86 
88  View() {
89  view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0;
90  resolution = 0; max_resolutions = 0;
91  width = 0; height = 0;
92  res_width = 0; res_height = 0;
93  min_size = 1; max_size = 0;
94  requested_width = 0; requested_height = 0;
95  contrast = 1.0; gamma = 1.0;
96  xangle = 0; yangle = 90;
97  shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0;
98  cmapped = false; cmap = HOT; inverted = false;
99  max_layers = 0; layers = 0;
100  rotation = 0.0; flip = 0;
101  maintain_aspect = true;
102  colourspace = NONE;
103  };
104 
105 
107 
108  void setContrast( float c ){ contrast = c; };
109 
110 
112 
113  void setMaxSize( unsigned int m ){ max_size = m; };
114 
115 
117  /* @return maximum output dimension */
118  unsigned int getMaxSize(){ return max_size; };
119 
120 
122 
123  void setMaxResolutions( unsigned int r ){ max_resolutions = r; resolution=r-1; };
124 
125 
127  /* @return requested width */
128  unsigned int getRequestWidth();
129 
130 
132 
133  void setRequestWidth( unsigned int w ){
134  if( (max_size > 0) && (w > max_size) ) requested_width = max_size;
135  else requested_width = w;
136  };
137 
138 
140  /* @return requested height */
141  unsigned int getRequestHeight();
142 
143 
145 
146  void setRequestHeight( unsigned int h ){
147  if( (max_size > 0) && (h > max_size) ) requested_height = max_size;
148  else requested_height = h;
149  };
150 
151 
153  /* @return requested resolution level */
154  unsigned int getResolution();
155 
156 
158  /* @return scaling factor */
159  float getScale();
160 
161 
163 
164  void setViewLeft( float x );
165 
166 
168 
169  void setViewTop( float y );
170 
171 
173 
174  void setViewWidth( float w );
175 
176 
178 
179  void setViewHeight( float h );
180 
181 
183 
186  void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; };
187 
188 
190 
191  void setMaxLayers( int l ){ max_layers = l; };
192 
194 
195  void setLayers( int l ){ layers = l; };
196 
198  int getLayers();
199 
201  /* @return requested contrast */
202  float getContrast(){ return contrast; };
203 
205  /* @return image width */
206  unsigned int getImageWidth(){ return width; };
207 
209  /* @return image height */
210  unsigned int getImageHeight(){ return height; };
211 
213  /* @return position of left of viewport in pixels */
214  unsigned int getViewLeft() ;
215 
217  /* @return position of top of viewport in pixels */
218  unsigned int getViewTop();
219 
221  /* @return width of viewport in pixels */
222  unsigned int getViewWidth();
223 
225  /* @return height of viewport in pixels */
226  unsigned int getViewHeight();
227 
229  /* @return boolean indicating whether viewport specified */
230  bool viewPortSet();
231 
233 
234  void setGamma( float g ){ gamma = g; };
235 
237  /* @return requested gamma */
238  float getGamma(){ return gamma; };
239 
241 
242  void setRotation( float r ){ rotation = r; };
243 
245  /* @return requested rotation angle in degrees */
246  float getRotation(){ return rotation; };
247 
250  if( contrast != 1.0 || gamma != 1.0 || cmapped || shaded || inverted || ctw.size() ){
251  return true;
252  }
253  else return false;
254  }
255 
256 };
257 
258 
259 #endif
void setRotation(float r)
Set rotation.
Definition: View.h:242
void setViewHeight(float h)
Set the height co-ordinate of the viewport.
void setImageSize(unsigned int w, unsigned int h)
Set the source image pixel size.
Definition: View.h:186
bool shaded
Vertical View.
Definition: View.h:74
unsigned int getViewTop()
Return the top pixel of the viewport.
float getRotation()
Get rotation.
Definition: View.h:246
std::vector< std::vector< float > > ctw
Requested colourspace.
Definition: View.h:82
void setContrast(float c)
Set the contrast adjustment.
Definition: View.h:108
int flip
Colour twist matrix.
Definition: View.h:83
int shade[3]
Whether to use shading view.
Definition: View.h:75
enum cmap_type cmap
Whether to modify colormap.
Definition: View.h:77
void setViewLeft(float x)
Set the left co-ordinate of the viewport.
void setLayers(int l)
Set the number of quality layers to decode, limiting to our max value.
Definition: View.h:195
void setViewWidth(float w)
Set the width co-ordinate of the viewport.
unsigned int getViewWidth()
Return the pixel width of the viewport.
bool inverted
colormap
Definition: View.h:78
void setGamma(float g)
Set gamma.
Definition: View.h:234
int getLayers()
Return the number of layers to decode.
float getGamma()
Get gamma.
Definition: View.h:238
unsigned int getResolution()
Return the requested resolution.
float getScale()
Return the scaling required in case our requested width or height is in between available resolutions...
int yangle
Horizontal View.
Definition: View.h:73
void setMaxSize(unsigned int m)
Set the maximum view port dimension.
Definition: View.h:113
unsigned int getImageHeight()
Return the image height at our requested resolution.
Definition: View.h:210
View()
Indicate whether aspect ratio should be maintained.
Definition: View.h:88
bool maintain_aspect
Flip (1=horizontal, 2=vertical)
Definition: View.h:84
bool viewPortSet()
Indicate whether the viewport has been set.
ColourSpaces colourspace
Number of quality layers.
Definition: View.h:81
Class to intelligently handle Image Transforms.
Definition: View.h:41
bool cmapped
Shading incident light angles (x,y,z)
Definition: View.h:76
bool floatProcessing()
Whether view requires floating point processing.
Definition: View.h:249
unsigned int getMaxSize()
Get the maximum allowed output size.
Definition: View.h:118
unsigned int getViewLeft()
Return the left pixel of the viewport.
unsigned int getImageWidth()
Return the image width at our requested resolution.
Definition: View.h:206
float getContrast()
Return the contrast adjustment.
Definition: View.h:202
unsigned int getRequestHeight()
Get the size of the requested height.
unsigned int getRequestWidth()
Get the size of the requested width.
unsigned int getViewHeight()
Return the pixel height of the viewport.
void setViewTop(float y)
Set the top co-ordinate of the viewport.
void setMaxLayers(int l)
Limit the maximum number of quality layers we are allowed to decode.
Definition: View.h:191
void setRequestWidth(unsigned int w)
Set the size of the requested width.
Definition: View.h:133
int layers
Maximum number of quality layers allowed.
Definition: View.h:80
void setMaxResolutions(unsigned int r)
Set the maximum view port dimension.
Definition: View.h:123
void setRequestHeight(unsigned int h)
Set the size of the requested height.
Definition: View.h:146
int max_layers
Whether to invert colormap.
Definition: View.h:79