21 #ifndef QGSCONTRASTENHANCEMENT_H
22 #define QGSCONTRASTENHANCEMENT_H
24 #include "qgis_core.h"
54 UserDefinedEnhancement
74 return std::numeric_limits<unsigned char>::max();
76 return std::numeric_limits<unsigned short>::max();
78 return std::numeric_limits<short>::max();
80 return std::numeric_limits<unsigned int>::max();
82 return std::numeric_limits<int>::max();
84 return std::numeric_limits<float>::max();
86 return std::numeric_limits<double>::max();
88 return std::numeric_limits<short>::max();
90 return std::numeric_limits<int>::max();
92 return std::numeric_limits<float>::max();
94 return std::numeric_limits<double>::max();
102 return std::numeric_limits<double>::max();
113 return std::numeric_limits<unsigned char>::min();
115 return std::numeric_limits<unsigned short>::min();
117 return std::numeric_limits<short>::min();
119 return std::numeric_limits<unsigned int>::min();
121 return std::numeric_limits<int>::min();
123 return std::numeric_limits<float>::max() * -1.0;
125 return std::numeric_limits<double>::max() * -1.0;
127 return std::numeric_limits<short>::min();
129 return std::numeric_limits<int>::min();
131 return std::numeric_limits<float>::max() * -1.0;
133 return std::numeric_limits<double>::max() * -1.0;
141 return std::numeric_limits<double>::max() * -1.0;
147 static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm
algorithm );
152 static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(
const QString &contrastEnhancementString );
165 int enhanceContrast(
double value );
171 bool isValueInDisplayableRange(
double value );
180 void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm
algorithm,
bool generateTable =
true );
198 void setMaximumValue(
double value,
bool generateTable =
true );
210 void setMinimumValue(
double value,
bool generateTable =
true );
212 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const;
214 void readXml(
const QDomElement &elem );
224 void toSld( QDomDocument &doc, QDomElement &element )
const;
232 ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm = NoEnhancement;
235 std::unique_ptr< QgsContrastEnhancementFunction > mContrastEnhancementFunction;
238 bool mEnhancementDirty =
false;
241 int *mLookupTable =
nullptr;
244 double mMinimumValue;
247 double mMaximumValue;
253 double mRasterDataTypeRange;
256 double mLookupTableOffset;
259 bool generateLookupTable();
262 int calculateContrastEnhancementValue(
double );