iipsrv 1.2
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-2022 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
36class View{
37
38
39 private:
40
41 // Resolution independent x,y,w,h region viewport in range 0 -> 1.0
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 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;
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 std::vector<float> convolution;
85 bool minmax;
86
87
89 View() {
90 view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0;
91 resolution = 0; max_resolutions = 0;
92 width = 0; height = 0;
93 res_width = 0; res_height = 0;
94 min_size = 1; max_size = 0;
95 requested_width = 0; requested_height = 0;
96 contrast = 1.0; gamma = 1.0;
97 xangle = 0; yangle = 90;
98 shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0;
99 cmapped = false; cmap = HOT; inverted = false;
100 max_layers = 0; layers = 0;
101 rotation = 0.0; flip = 0;
102 maintain_aspect = true;
103 allow_upscaling = true;
104 colourspace = NONE;
105 embed_icc = true;
106 output_format = JPEG;
107 equalization = false;
108 minmax = false;
109 };
110
111
113
114 void setMaxSize( int m ){ max_size = m; };
115
116
118 /* @return maximum output dimension */
119 int getMaxSize(){ return max_size; };
120
121
123 /* @return minimum output dimension */
124 unsigned int getMinSize(){ return min_size; };
125
126
128
129 void setAllowUpscaling( bool upscale ){ allow_upscaling = upscale; };
130
131
133 /* @return true or false */
135
136
138
140 void setEmbedICC( bool embed ){ embed_icc = embed; };
141
142
144
146 bool embedICC(){
147 // Disable if colour-mapping, twist, hill-shading or greyscale conversion applied
148 if( cmapped || shaded || ctw.size() || colourspace==GREYSCALE ) return false;
149 return embed_icc;
150 };
151
152
154
155 void setMaxResolutions( unsigned int r ){ max_resolutions = r; resolution=r-1; };
156
157
159 /* @return requested width */
160 unsigned int getRequestWidth();
161
162
164
165 void setRequestWidth( unsigned int w ){
166 requested_width = w;
167 };
168
169
171 /* @return requested height */
172 unsigned int getRequestHeight();
173
174
176
177 void setRequestHeight( unsigned int h ){
178 requested_height = h;
179 };
180
181
183 /* @return requested resolution level */
184 unsigned int getResolution();
185
186
188 /* @return scaling factor */
189 float getScale();
190
191
193
194 void setViewLeft( float x );
195
196
198
199 void setViewTop( float y );
200
201
203
204 void setViewWidth( float w );
205
206
208
209 void setViewHeight( float h );
210
211
213
216 void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; };
217
218
220
221 void setMaxLayers( int l ){ max_layers = l; };
222
224
225 void setLayers( int l ){ layers = l; };
226
229
231 /* @return image width */
232 unsigned int getImageWidth(){ return width; };
233
235 /* @return image height */
236 unsigned int getImageHeight(){ return height; };
237
239 /* @return position of left of viewport in pixels */
240 unsigned int getViewLeft() ;
241
243 /* @return position of top of viewport in pixels */
244 unsigned int getViewTop();
245
247 /* @return width of viewport in pixels */
248 unsigned int getViewWidth();
249
251 /* @return height of viewport in pixels */
252 unsigned int getViewHeight();
253
255 /* @return boolean indicating whether viewport specified */
257
259
260 void setRotation( float r ){ rotation = r; };
261
263 /* @return requested rotation angle in degrees */
264 float getRotation(){ return rotation; };
265
268 if( contrast != 1.0 || gamma != 1.0 || cmapped || shaded || inverted || minmax || ctw.size() || convolution.size() ){
269 return true;
270 }
271 else return false;
272 }
273
276 if( equalization || colourspace==BINARY || contrast==-1 ) return true;
277 else return false;
278 }
279
280};
281
282
283#endif
Class to intelligently handle Image Transforms.
Definition: View.h:36
bool embed_icc
Indicate whether images may be served larger than the source file.
Definition: View.h:79
float contrast
Requested output format.
Definition: View.h:81
bool viewPortSet()
Indicate whether the viewport has been set.
unsigned int getViewWidth()
Return the pixel width of the viewport.
void setMaxSize(int m)
Set the maximum view port dimension.
Definition: View.h:114
unsigned int getViewTop()
Return the top pixel of the viewport.
int yangle
Horizontal View.
Definition: View.h:66
unsigned int getResolution()
Return the resolution level needed for the requested view.
unsigned int getMinSize()
Get the minimum allowed output size.
Definition: View.h:124
void setViewTop(float y)
Set the top co-ordinate of the viewport.
bool embedICC()
Get the embed_icc flag - disable in case of certain types of processing.
Definition: View.h:146
float getScale()
Return the scaling required in case our requested width or height is in between available resolutions...
unsigned int getViewLeft()
Return the left pixel of the viewport.
void setViewWidth(float w)
Set the width co-ordinate of the viewport.
View()
Whether to perform contrast stretching using user-defined min/max.
Definition: View.h:89
std::vector< float > convolution
Gamma adjustment requested by GAM command.
Definition: View.h:83
bool requireHistogram()
Whether we require a histogram.
Definition: View.h:275
bool minmax
Whether to perform histogram equalization.
Definition: View.h:85
int flip
Colour twist matrix.
Definition: View.h:76
bool maintain_aspect
Flip (1=horizontal, 2=vertical)
Definition: View.h:77
bool equalization
Convolution matrix.
Definition: View.h:84
float getRotation()
Get rotation.
Definition: View.h:264
bool shaded
Vertical View.
Definition: View.h:67
int max_layers
Whether to invert colormap.
Definition: View.h:72
float gamma
Contrast adjustment requested by CNT command.
Definition: View.h:82
unsigned int getRequestWidth()
Get the size of the requested width.
int shade[3]
Whether to use shading view.
Definition: View.h:68
int getMaxSize()
Get the maximum allowed output size.
Definition: View.h:119
void setRequestWidth(unsigned int w)
Set the size of the requested width.
Definition: View.h:165
unsigned int getRequestHeight()
Get the size of the requested height.
bool allow_upscaling
Indicate whether aspect ratio should be maintained.
Definition: View.h:78
void setEmbedICC(bool embed)
Set the embed_icc flag.
Definition: View.h:140
CompressionType output_format
Indicate whether we should embed ICC profiles.
Definition: View.h:80
unsigned int getImageHeight()
Return the image height at our requested resolution.
Definition: View.h:236
void setMaxResolutions(unsigned int r)
Set the maximum view port dimension.
Definition: View.h:155
int getLayers()
Return the number of layers to decode.
bool cmapped
Shading incident light angles (x,y,z)
Definition: View.h:69
unsigned int getImageWidth()
Return the image width at our requested resolution.
Definition: View.h:232
int layers
Maximum number of quality layers allowed.
Definition: View.h:73
void setImageSize(unsigned int w, unsigned int h)
Set the source image pixel size.
Definition: View.h:216
void setViewHeight(float h)
Set the height co-ordinate of the viewport.
bool allowUpscaling()
Get the allow_upscaling flag.
Definition: View.h:134
void setMaxLayers(int l)
Limit the maximum number of quality layers we are allowed to decode.
Definition: View.h:221
void setAllowUpscaling(bool upscale)
Set the allow_upscaling flag.
Definition: View.h:129
bool floatProcessing()
Whether view requires floating point processing.
Definition: View.h:267
void setViewLeft(float x)
Set the left co-ordinate of the viewport.
ColourSpaces colourspace
Number of quality layers.
Definition: View.h:74
void setRotation(float r)
Set rotation.
Definition: View.h:260
enum cmap_type cmap
Whether to modify colormap.
Definition: View.h:70
void setRequestHeight(unsigned int h)
Set the size of the requested height.
Definition: View.h:177
bool inverted
colormap
Definition: View.h:71
unsigned int getViewHeight()
Return the pixel height of the viewport.
void setLayers(int l)
Set the number of quality layers to decode, limiting to our max value.
Definition: View.h:225
std::vector< std::vector< float > > ctw
Requested colourspace.
Definition: View.h:75