@@ -816,7 +816,8 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
816
816
}
817
817
else
818
818
{
819
- QgsSingleBandGrayRenderer r ( mDataProvider , bandNumber ( mGrayBandName ), mResampler );
819
+ int grayBand = bandNumber ( mGrayBandName );
820
+ QgsSingleBandGrayRenderer r ( mDataProvider , grayBand, mResampler );
820
821
r.setOpacity ( mTransparencyLevel / 255.0 );
821
822
r.setRasterTransparency ( &mRasterTransparency );
822
823
if ( mTransparencyBandName != TRSTRING_NOT_SET )
@@ -828,6 +829,21 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
828
829
}
829
830
}
830
831
r.setInvertColor ( mInvertColor );
832
+ if ( QgsContrastEnhancement::NoEnhancement != contrastEnhancementAlgorithm () && !mUserDefinedGrayMinimumMaximum && mStandardDeviations > 0 )
833
+ {
834
+ mGrayMinimumMaximumEstimated = false ;
835
+ QgsRasterBandStats myGrayBandStats = bandStatistics ( grayBand );
836
+ setMaximumValue ( grayBand, myGrayBandStats.mean + ( mStandardDeviations * myGrayBandStats.stdDev ) );
837
+ setMinimumValue ( grayBand, myGrayBandStats.mean - ( mStandardDeviations * myGrayBandStats.stdDev ) );
838
+ r.setContrastEnhancement ( contrastEnhancement ( grayBand ) );
839
+ }
840
+ else if ( QgsContrastEnhancement::NoEnhancement != contrastEnhancementAlgorithm () && !mUserDefinedGrayMinimumMaximum )
841
+ {
842
+ mGrayMinimumMaximumEstimated = true ;
843
+ setMaximumValue ( grayBand, mDataProvider ->maximumValue ( grayBand ) );
844
+ setMinimumValue ( grayBand, mDataProvider ->minimumValue ( grayBand ) );
845
+ r.setContrastEnhancement ( contrastEnhancement ( grayBand ) );
846
+ }
831
847
r.draw ( theQPainter, theRasterViewPort, theQgsMapToPixel );
832
848
833
849
#if 0
0 commit comments