QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
raster
qgscontrastenhancementfunction.cpp
Go to the documentation of this file.
1
/* **************************************************************************
2
qgscontrastenhancementfunction.cpp - description
3
-------------------
4
begin : Fri Nov 16 2007
5
copyright : (C) 2007 by Peter J. Ersts
6
email :
[email protected]
7
8
****************************************************************************/
9
10
/* **************************************************************************
11
* *
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
16
* *
17
***************************************************************************/
18
19
#include "
qgscontrastenhancementfunction.h
"
20
21
QgsContrastEnhancementFunction::QgsContrastEnhancementFunction
(
QGis::DataType
theDataType,
double
theMinimumValue,
double
theMaximumValue )
22
{
23
mQgsRasterDataType
= theDataType;
24
mMaximumValue
= theMaximumValue;
25
mMinimumValue
= theMinimumValue;
26
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
27
}
28
29
QgsContrastEnhancementFunction::QgsContrastEnhancementFunction
(
const
QgsContrastEnhancementFunction
& f )
30
{
31
mQgsRasterDataType
= f.
mQgsRasterDataType
;
32
mMaximumValue
= f.
mMaximumValue
;
33
mMinimumValue
= f.
mMinimumValue
;
34
mMinimumMaximumRange
= f.
mMinimumMaximumRange
;
35
}
36
37
int
QgsContrastEnhancementFunction::enhance
(
double
theValue )
38
{
39
if
(
mQgsRasterDataType
==
QGis::Byte
)
40
{
41
return
static_cast<
int
>
( theValue );
42
}
43
else
44
{
45
return
static_cast<
int
>
(((( theValue -
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) ) / (
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) -
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) ) )*255.0 ) );
46
}
47
}
48
49
bool
QgsContrastEnhancementFunction::isValueInDisplayableRange
(
double
theValue )
50
{
51
//A default check is to see if the provided value is with the range for the data type
52
if
( theValue <
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) || theValue >
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) )
53
{
54
return
false
;
55
}
56
57
return
true
;
58
}
59
60
void
QgsContrastEnhancementFunction::setMaximumValue
(
double
theValue )
61
{
62
if
(
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) < theValue )
63
{
64
mMaximumValue
=
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
);
65
}
66
else
67
{
68
mMaximumValue
= theValue;
69
}
70
71
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
72
}
73
74
void
QgsContrastEnhancementFunction::setMinimumValue
(
double
theValue )
75
{
76
77
if
(
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) > theValue )
78
{
79
mMinimumValue
=
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
);
80
}
81
else
82
{
83
mMinimumValue
= theValue;
84
}
85
86
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
87
}
Generated on Sun May 10 2015 16:33:25 for QGIS API Documentation by
1.8.1.2