@@ -1443,9 +1443,14 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter, QgsRasterViewPor
1443
1443
}
1444
1444
else if (QgsContrastEnhancement::NO_STRETCH != getContrastEnhancementAlgorithm () && !mUserDefinedGrayMinMaxFlag )
1445
1445
{
1446
- myGrayBandStats = getRasterBandStats (theBandNo);
1447
- setMaximumValue (theBandNo, myGrayBandStats.maxVal );
1448
- setMinimumValue (theBandNo, myGrayBandStats.minVal );
1446
+ // This case will be true the first time the image is loaded, so just approimate the min max to keep
1447
+ // from calling generate raster band stats
1448
+ double GDALrange[2 ];
1449
+ GDALComputeRasterMinMax ( myGdalBand, 1 , GDALrange ); // Approximate
1450
+
1451
+ setMaximumValue (theBandNo, GDALrange[1 ]);
1452
+ setMinimumValue (theBandNo, GDALrange[0 ]);
1453
+
1449
1454
}
1450
1455
1451
1456
QgsDebugMsg (" Starting main render loop" );
@@ -2078,16 +2083,20 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
2078
2083
}
2079
2084
else if (QgsContrastEnhancement::NO_STRETCH != getContrastEnhancementAlgorithm () && !mUserDefinedRGBMinMaxFlag )
2080
2085
{
2081
- myRedBandStats = getRasterBandStats (myRedBandNo);
2082
- myGreenBandStats = getRasterBandStats (myGreenBandNo);
2083
- myBlueBandStats = getRasterBandStats (myBlueBandNo);
2086
+ // This case will be true the first time the image is loaded, so just approimate the min max to keep
2087
+ // from calling generate raster band stats
2088
+ double GDALrange[2 ];
2089
+ GDALComputeRasterMinMax ( myGdalRedBand, 1 , GDALrange ); // Approximate
2090
+ setMaximumValue (myRedBandNo, GDALrange[1 ]);
2091
+ setMinimumValue (myRedBandNo, GDALrange[0 ]);
2084
2092
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 );
2093
+ GDALComputeRasterMinMax ( myGdalGreenBand, 1 , GDALrange ); // Approximate
2094
+ setMaximumValue (myGreenBandNo, GDALrange[1 ]);
2095
+ setMinimumValue (myGreenBandNo, GDALrange[0 ]);
2096
+
2097
+ GDALComputeRasterMinMax ( myGdalBlueBand, 1 , GDALrange ); // Approximate
2098
+ setMaximumValue (myBlueBandNo, GDALrange[1 ]);
2099
+ setMinimumValue (myBlueBandNo, GDALrange[0 ]);
2091
2100
}
2092
2101
2093
2102
// Read and display pixels
0 commit comments