Skip to content

Commit

Permalink
Fix singlebandgrayrenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 1, 2012
1 parent dec227f commit 83f3d75
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,14 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
QgsRasterBandStats myGrayBandStats = bandStatistics( grayBand );
setMaximumValue( grayBand, myGrayBandStats.mean + ( mStandardDeviations * myGrayBandStats.stdDev ) );
setMinimumValue( grayBand, myGrayBandStats.mean - ( mStandardDeviations * myGrayBandStats.stdDev ) );
r.setContrastEnhancement( contrastEnhancement( grayBand ) );
}
else if ( QgsContrastEnhancement::NoEnhancement != contrastEnhancementAlgorithm() && !mUserDefinedGrayMinimumMaximum )
{
mGrayMinimumMaximumEstimated = true;
setMaximumValue( grayBand, mDataProvider->maximumValue( grayBand ) );
setMinimumValue( grayBand, mDataProvider->minimumValue( grayBand ) );
r.setContrastEnhancement( contrastEnhancement( grayBand ) );
setMinimumValue( grayBand, mDataProvider->minimumValue( grayBand ) );
}
r.setContrastEnhancement( contrastEnhancement( grayBand ) );
r.draw( theQPainter, theRasterViewPort, theQgsMapToPixel );

#if 0
Expand Down
9 changes: 9 additions & 0 deletions src/core/raster/qgssinglebandgrayrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void QgsSingleBandGrayRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort,
void* rasterData;
//double currentOpacity = mOpacity;
int grayVal;
QRgb myDefaultColor = qRgba( 0, 0, 0, 0 );


while ( readNextRasterPart( mGrayBand, viewPort, nCols, nRows, &rasterData, topLeftCol, topLeftRow ) )
{
Expand All @@ -60,8 +62,15 @@ void QgsSingleBandGrayRenderer::draw( QPainter* p, QgsRasterViewPort* viewPort,
for ( int j = 0; j < nCols; ++j )
{
grayVal = readValue( rasterData, rasterType, currentRasterPos );

if ( mContrastEnhancement )
{
if ( !mContrastEnhancement->isValueInDisplayableRange( grayVal ) )
{
imageScanLine[ j ] = myDefaultColor;
++currentRasterPos;
continue;
}
grayVal = mContrastEnhancement->enhanceContrast( grayVal );
}

Expand Down

0 comments on commit 83f3d75

Please sign in to comment.