iipsrv  0.9.9
View.h
1 /*
2  Image View Parameters
3 
4  Copyright (C) 2003-2009 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 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 
21 
22 #ifndef _VIEW_H
23 #define _VIEW_H
24 
25 
26 #include <cstddef>
27 
28 
30 
31 class View{
32 
33 
34  private:
35 
36  // Resolution independent x,y,w,h region viewport
37  float view_left, view_top, view_width, view_height;
38 
39  int resolution;
40  unsigned int max_resolutions;
41  unsigned int left, top, width, height;
42  unsigned int min_size;
43  unsigned int max_size;
44  unsigned int requested_width;
45  unsigned int requested_height;
46  float contrast;
47 
48 
51 
54  void calculateResolution( unsigned int m, unsigned int r );
55 
56 
57  public:
58 
59  int xangle;
60  int yangle;
61  bool shaded;
62  int shade[3];
63  int max_layers;
64  int layers;
65 
66 
68  View() {
69  resolution = 0; max_resolutions = 0; min_size = 8; max_size = 0;
70  width = 0; height = 0;
71  view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0;
72  requested_width = 0; requested_height = 0;
73  contrast = 1.0;
74  xangle = 0; yangle = 90;
75  shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0;
76  max_layers = 0; layers = 0;
77  };
78 
79 
81 
82  void setContrast( float c ){ contrast = c; };
83 
84 
86 
87  void setMaxSize( unsigned int m ){ max_size = m; };
88 
89 
91 
92  void setMaxResolutions( unsigned int r ){ max_resolutions = r; };
93 
94 
96  unsigned int getRequestWidth(){
97  if( requested_width == 0 && requested_height > 0 ){
98  requested_width = static_cast<unsigned int>( width * requested_height / height );
99  }
100  if( requested_width > width ) requested_width = width;
101  if( requested_width > max_size ) requested_width = max_size;
102  // If no width has been set, use our full size
103  if( requested_width <= 0 ) requested_width = width;
104  return requested_width;
105  };
106 
107 
109 
110  void setRequestWidth( unsigned int w ){
111  if( w < max_size ) requested_width = w;
112  else requested_width = max_size;
113  };
114 
115 
117  unsigned int getRequestHeight(){
118  if( requested_height == 0 && requested_width > 0 ){
119  requested_height = static_cast<unsigned int>( height * requested_width / width );
120  }
121  if( requested_height > height ) requested_height = height;
122  if( requested_height > max_size ) requested_height = max_size;
123  // If no height has been set, use our full size
124  if( requested_height <= 0 ) requested_height = height;
125  return requested_height;
126  };
127 
129 
130  void setRequestHeight( unsigned int h ){
131  if( h < max_size ) requested_height = h;
132  else requested_height = max_size;
133  };
134 
135 
137  unsigned int getResolution();
138 
139 
141  float getScale();
142 
143 
145 
146  void setViewLeft( float x );
147 
148 
150 
151  void setViewTop( float y );
152 
153 
155 
156  void setViewWidth( float w );
157 
158 
160 
161  void setViewHeight( float h );
162 
163 
165 
168  void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; };
169 
170 
172 
173  void setMaxLayers( int l ){ max_layers = l; };
174 
176 
177  void setLayers( int l ){ layers = ( l<max_layers )? l : max_layers; };
178 
180  unsigned int getLayers(){ return layers; };
181 
183  float getContrast(){ return contrast; };
184 
186  unsigned int getImageWidth(){ return width; };
187 
189  unsigned int getImageHeight(){ return height; };
190 
192  unsigned int getViewLeft() ;
193 
195  unsigned int getViewTop();
196 
198  unsigned int getViewWidth();
199 
201  unsigned int getViewHeight();
202 
204  bool viewPortSet();
205 
206 
207 };
208 
209 
210 #endif
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:168
bool shaded
Vertical View.
Definition: View.h:61
unsigned int getViewTop()
Return the top pixel of the viewport.
void setContrast(float c)
Set the contrast adjustment.
Definition: View.h:82
int shade[3]
Whether to use shading view.
Definition: View.h:62
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:177
void setViewWidth(float w)
Set the width co-ordinate of the viewport.
unsigned int getViewWidth()
Return the pixel width of the viewport.
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:60
unsigned int getLayers()
Return the number of layers to decode.
Definition: View.h:180
void setMaxSize(unsigned int m)
Set the maximum view port dimension.
Definition: View.h:87
unsigned int getImageHeight()
Return the image height at our requested resolution.
Definition: View.h:189
View()
Number of quality layers.
Definition: View.h:68
bool viewPortSet()
Indicate whether the viewport has been set.
Class to intelligently handle Image Transforms.
Definition: View.h:31
unsigned int getViewLeft()
Return the left pixel of the viewport.
unsigned int getImageWidth()
Return the image width at our requested resolution.
Definition: View.h:186
float getContrast()
Return the contrast adjustment.
Definition: View.h:183
unsigned int getRequestHeight()
Get the size of the requested height.
Definition: View.h:117
unsigned int getRequestWidth()
Get the size of the requested width.
Definition: View.h:96
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:173
void setRequestWidth(unsigned int w)
Set the size of the requested width.
Definition: View.h:110
int layers
Maximum number of quality layers allowed.
Definition: View.h:64
void setMaxResolutions(unsigned int r)
Set the maximum view port dimension.
Definition: View.h:92
void setRequestHeight(unsigned int h)
Set the size of the requested height.
Definition: View.h:130
int max_layers
Shading incident light angles (x,y,z)
Definition: View.h:63