Quantum GIS API Documentation
1.7.5-Wroclaw
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
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 : ersts@amnh.org
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
(
QgsContrastEnhancement::QgsRasterDataType
theDataType,
double
theMinimumValue,
double
theMaximumValue )
22
{
23
mQgsRasterDataType
= theDataType;
24
mMaximumValue
= theMaximumValue;
25
mMinimumValue
= theMinimumValue;
26
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
27
}
28
29
30
int
QgsContrastEnhancementFunction::enhance
(
double
theValue )
31
{
32
if
(
mQgsRasterDataType
==
QgsContrastEnhancement::QGS_Byte
)
33
{
34
return
static_cast<
int
>
( theValue );
35
}
36
else
37
{
38
return
static_cast<
int
>
(((( theValue -
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) ) / (
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) -
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) ) )*255.0 ) );
39
}
40
}
41
42
bool
QgsContrastEnhancementFunction::isValueInDisplayableRange
(
double
theValue )
43
{
44
//A default check is to see if the provided value is with the range for the data type
45
if
( theValue <
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) || theValue >
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) )
46
{
47
return
false
;
48
}
49
50
return
true
;
51
}
52
53
void
QgsContrastEnhancementFunction::setMaximumValue
(
double
theValue )
54
{
55
if
(
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
) < theValue )
56
{
57
mMaximumValue
=
QgsContrastEnhancement::maximumValuePossible
(
mQgsRasterDataType
);
58
}
59
else
60
{
61
mMaximumValue
= theValue;
62
}
63
64
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
65
}
66
67
void
QgsContrastEnhancementFunction::setMinimumValue
(
double
theValue )
68
{
69
70
if
(
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
) > theValue )
71
{
72
mMinimumValue
=
QgsContrastEnhancement::minimumValuePossible
(
mQgsRasterDataType
);
73
}
74
else
75
{
76
mMinimumValue
= theValue;
77
}
78
79
mMinimumMaximumRange
=
mMaximumValue
-
mMinimumValue
;
80
}
Generated on Thu Sep 19 2013 17:30:55 for Quantum GIS API Documentation by
1.8.4