View.h
/*
Image View and Transform Parameters
Copyright (C) 2003-2019 Ruven Pillay.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _VIEW_H
#define _VIEW_H
#include <cstddef>
#include <vector>
#include "Transforms.h"
class View{
private:
// Resolution independent x,y,w,h region viewport
float view_left, view_top, view_width, view_height;
int resolution;
unsigned int max_resolutions;
unsigned int width, height;
unsigned int res_width, res_height;
unsigned int min_size;
unsigned int max_size;
unsigned int requested_width;
unsigned int requested_height;
float rotation;
void calculateResolution( unsigned int m, unsigned int r );
public:
int xangle;
int yangle;
bool shaded;
int shade[3];
bool cmapped;
enum cmap_type cmap;
bool inverted;
int max_layers;
int layers;
ColourSpaces colourspace;
std::vector< std::vector<float> > ctw;
int flip;
bool maintain_aspect;
bool allow_upscaling;
bool embed_icc;
CompressionType output_format;
float contrast;
float gamma;
bool equalization;
View() {
view_left = 0.0; view_top = 0.0; view_width = 1.0; view_height = 1.0;
resolution = 0; max_resolutions = 0;
width = 0; height = 0;
res_width = 0; res_height = 0;
min_size = 1; max_size = 0;
requested_width = 0; requested_height = 0;
contrast = 1.0; gamma = 1.0;
xangle = 0; yangle = 90;
shaded = false; shade[0] = 0; shade[1] = 0; shade[2] = 0;
cmapped = false; cmap = HOT; inverted = false;
max_layers = 0; layers = 0;
rotation = 0.0; flip = 0;
maintain_aspect = true;
allow_upscaling = true;
colourspace = NONE;
embed_icc = true;
output_format = JPEG;
equalization = false;
};
void setMaxSize( unsigned int m ){ max_size = m; };
/* @return maximum output dimension */
unsigned int getMaxSize(){ return max_size; };
void setAllowUpscaling( bool upscale ){ allow_upscaling = upscale; };
/* @return true or false */
bool allowUpscaling(){ return allow_upscaling; };
void setEmbedICC( bool embed ){ embed_icc = embed; };
bool embedICC(){
// Disable if colour-mapping, twist, hill-shading or greyscale conversion applied
if( cmapped || shaded || ctw.size() || colourspace==GREYSCALE ) return false;
return embed_icc;
};
void setMaxResolutions( unsigned int r ){ max_resolutions = r; resolution=r-1; };
/* @return requested width */
unsigned int getRequestWidth();
void setRequestWidth( unsigned int w ){
requested_width = w;
};
/* @return requested height */
unsigned int getRequestHeight();
void setRequestHeight( unsigned int h ){
requested_height = h;
};
/* @return requested resolution level */
unsigned int getResolution();
/* @return scaling factor */
float getScale();
void setViewLeft( float x );
void setViewTop( float y );
void setViewWidth( float w );
void setViewHeight( float h );
void setImageSize( unsigned int w, unsigned int h ){ width = w; height = h; };
void setMaxLayers( int l ){ max_layers = l; };
void setLayers( int l ){ layers = l; };
int getLayers();
/* @return image width */
unsigned int getImageWidth(){ return width; };
/* @return image height */
unsigned int getImageHeight(){ return height; };
/* @return position of left of viewport in pixels */
unsigned int getViewLeft() ;
/* @return position of top of viewport in pixels */
unsigned int getViewTop();
/* @return width of viewport in pixels */
unsigned int getViewWidth();
/* @return height of viewport in pixels */
unsigned int getViewHeight();
/* @return boolean indicating whether viewport specified */
bool viewPortSet();
void setRotation( float r ){ rotation = r; };
/* @return requested rotation angle in degrees */
float getRotation(){ return rotation; };
bool floatProcessing(){
if( contrast != 1.0 || gamma != 1.0 || cmapped || shaded || inverted || ctw.size() ){
return true;
}
else return false;
}
bool requireHistogram(){
if( equalization || colourspace==BINARY || contrast==-1 ) return true;
else return false;
}
};
#endif
View::embed_icc
bool embed_icc
Indicate whether images may be served larger than the source file.
Definition View.h:79
View::contrast
float contrast
Requested output format.
Definition View.h:81
View::viewPortSet
bool viewPortSet()
Indicate whether the viewport has been set.
View::getViewWidth
unsigned int getViewWidth()
Return the pixel width of the viewport.
View::getViewTop
unsigned int getViewTop()
Return the top pixel of the viewport.
View::yangle
int yangle
Horizontal View.
Definition View.h:66
View::getResolution
unsigned int getResolution()
Return the requested resolution.
View::setViewTop
void setViewTop(float y)
Set the top co-ordinate 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::getScale
float getScale()
Return the scaling required in case our requested width or height is in between available resolutions...
View::getViewLeft
unsigned int getViewLeft()
Return the left pixel of the viewport.
View::setViewWidth
void setViewWidth(float w)
Set the width co-ordinate of the viewport.
View::View
View()
Whether to perform histogram equalization.
Definition View.h:87
View::requireHistogram
bool requireHistogram()
Whether we require a histogram.
Definition View.h:267
View::flip
int flip
Colour twist matrix.
Definition View.h:76
View::maintain_aspect
bool maintain_aspect
Flip (1=horizontal, 2=vertical).
Definition View.h:77
View::equalization
bool equalization
Gamma adjustment requested by GAM command.
Definition View.h:83
View::getRotation
float getRotation()
Get rotation.
Definition View.h:256
View::shaded
bool shaded
Vertical View.
Definition View.h:67
View::max_layers
int max_layers
Whether to invert colormap.
Definition View.h:72
View::gamma
float gamma
Contrast adjustment requested by CNT command.
Definition View.h:82
View::getRequestWidth
unsigned int getRequestWidth()
Get the size of the requested width.
View::shade
int shade[3]
Whether to use shading view.
Definition View.h:68
View::getMaxSize
unsigned int getMaxSize()
Get the maximum allowed output size.
Definition View.h:116
View::setRequestWidth
void setRequestWidth(unsigned int w)
Set the size of the requested width.
Definition View.h:157
View::getRequestHeight
unsigned int getRequestHeight()
Get the size of the requested height.
View::allow_upscaling
bool allow_upscaling
Indicate whether aspect ratio should be maintained.
Definition View.h:78
View::setEmbedICC
void setEmbedICC(bool embed)
Set the embed_icc flag.
Definition View.h:132
View::output_format
CompressionType output_format
Indicate whether we should embed ICC profiles.
Definition View.h:80
View::setMaxSize
void setMaxSize(unsigned int m)
Set the maximum view port dimension.
Definition View.h:111
View::getImageHeight
unsigned int getImageHeight()
Return the image height at our requested resolution.
Definition View.h:228
View::setMaxResolutions
void setMaxResolutions(unsigned int r)
Set the maximum view port dimension.
Definition View.h:147
View::getLayers
int getLayers()
Return the number of layers to decode.
View::cmapped
bool cmapped
Shading incident light angles (x,y,z).
Definition View.h:69
View::getImageWidth
unsigned int getImageWidth()
Return the image width at our requested resolution.
Definition View.h:224
View::layers
int layers
Maximum number of quality layers allowed.
Definition View.h:73
View::setImageSize
void setImageSize(unsigned int w, unsigned int h)
Set the source image pixel size.
Definition View.h:208
View::setViewHeight
void setViewHeight(float h)
Set the height co-ordinate of the viewport.
View::allowUpscaling
bool allowUpscaling()
Get the allow_upscaling flag.
Definition View.h:126
View::setMaxLayers
void setMaxLayers(int l)
Limit the maximum number of quality layers we are allowed to decode.
Definition View.h:213
View::setAllowUpscaling
void setAllowUpscaling(bool upscale)
Set the allow_upscaling flag.
Definition View.h:121
View::floatProcessing
bool floatProcessing()
Whether view requires floating point processing.
Definition View.h:259
View::setViewLeft
void setViewLeft(float x)
Set the left co-ordinate of the viewport.
View::colourspace
ColourSpaces colourspace
Number of quality layers.
Definition View.h:74
View::setRotation
void setRotation(float r)
Set rotation.
Definition View.h:252
View::cmap
enum cmap_type cmap
Whether to modify colormap.
Definition View.h:70
View::setRequestHeight
void setRequestHeight(unsigned int h)
Set the size of the requested height.
Definition View.h:169
View::inverted
bool inverted
colormap
Definition View.h:71
View::getViewHeight
unsigned int getViewHeight()
Return the pixel height of the viewport.
View::setLayers
void setLayers(int l)
Set the number of quality layers to decode, limiting to our max value.
Definition View.h:217
View::ctw
std::vector< std::vector< float > > ctw
Requested colourspace.
Definition View.h:75