@@ -392,7 +392,6 @@ QgsRasterLayer::QgsRasterLayer(QString const & path, QString const & baseName)
392
392
{
393
393
mUserDefinedRGBMinMaxFlag = false ; // defaults needed to bypass stretch
394
394
mUserDefinedGrayMinMaxFlag = false ;
395
- setContrastEnhancementAlgorithm (QgsContrastEnhancement::NO_STRETCH); // defaults needed to bypass stretch
396
395
397
396
mRasterShader = new QgsRasterShader ();
398
397
@@ -579,6 +578,8 @@ bool QgsRasterLayer::readFile( QString const & fileName )
579
578
mContrastEnhancementList .append (myContrastEnhancement);
580
579
}
581
580
581
+ setContrastEnhancementAlgorithm (QgsContrastEnhancement::STRETCH_TO_MINMAX); // defaults - Needs to be set after the Contrast list has been build
582
+
582
583
// decide what type of layer this is...
583
584
// note that multiband images can have one or more 'undefindd' bands,
584
585
// so we must do this check first!
@@ -1440,6 +1441,12 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter, QgsRasterViewPor
1440
1441
setMaximumValue (theBandNo, myGrayBandStats.mean + (mStandardDeviations * myGrayBandStats.stdDev ));
1441
1442
setMinimumValue (theBandNo, myGrayBandStats.mean - (mStandardDeviations * myGrayBandStats.stdDev ));
1442
1443
}
1444
+ else if (QgsContrastEnhancement::NO_STRETCH != getContrastEnhancementAlgorithm () && !mUserDefinedGrayMinMaxFlag )
1445
+ {
1446
+ myGrayBandStats = getRasterBandStats (theBandNo);
1447
+ setMaximumValue (theBandNo, myGrayBandStats.maxVal );
1448
+ setMinimumValue (theBandNo, myGrayBandStats.minVal );
1449
+ }
1443
1450
1444
1451
QgsDebugMsg (" Starting main render loop" );
1445
1452
// print each point in myGdalScanData with equal parts R, G ,B o make it show as gray
@@ -2069,6 +2076,19 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
2069
2076
setMaximumValue (myBlueBandNo, myBlueBandStats.mean + (mStandardDeviations * myBlueBandStats.stdDev ));
2070
2077
setMinimumValue (myBlueBandNo, myBlueBandStats.mean - (mStandardDeviations * myBlueBandStats.stdDev ));
2071
2078
}
2079
+ else if (QgsContrastEnhancement::NO_STRETCH != getContrastEnhancementAlgorithm () && !mUserDefinedRGBMinMaxFlag )
2080
+ {
2081
+ myRedBandStats = getRasterBandStats (myRedBandNo);
2082
+ myGreenBandStats = getRasterBandStats (myGreenBandNo);
2083
+ myBlueBandStats = getRasterBandStats (myBlueBandNo);
2084
+
2085
+ setMaximumValue (myRedBandNo, myRedBandStats.maxVal );
2086
+ setMinimumValue (myRedBandNo, myRedBandStats.minVal );
2087
+ setMaximumValue (myGreenBandNo, myGreenBandStats.maxVal );
2088
+ setMinimumValue (myGreenBandNo, myGreenBandStats.minVal );
2089
+ setMaximumValue (myBlueBandNo, myBlueBandStats.maxVal );
2090
+ setMinimumValue (myBlueBandNo, myBlueBandStats.minVal );
2091
+ }
2072
2092
2073
2093
// Read and display pixels
2074
2094
double myRedValue = 0.0 ;
0 commit comments