Skip to content
Permalink
Browse files

Add backward compatibility code to rasterlayer and fix render checker…

…. Landsat basic passes now
  • Loading branch information
mhugent committed Jun 18, 2012
1 parent 5b09b96 commit 60221439f0861396a80ae0815bac94da83d31f4a
Showing with 66 additions and 5 deletions.
  1. +64 −5 src/core/raster/qgsrasterlayer.cpp
  2. +2 −0 tests/src/core/qgsrenderchecker.cpp
@@ -2613,13 +2613,72 @@ void QgsRasterLayer::setColorShadingAlgorithm( QString theShaderAlgorithm )

void QgsRasterLayer::setContrastEnhancementAlgorithm( QgsContrastEnhancement::ContrastEnhancementAlgorithm theAlgorithm, bool theGenerateLookupTableFlag )
{
QList<QgsContrastEnhancement>::iterator myIterator = mContrastEnhancementList.begin();
while ( myIterator != mContrastEnhancementList.end() )
if ( !mRenderer || !mDataProvider )
{
( *myIterator ).setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
++myIterator;
return;
}

QString rendererType = mRenderer->type();
if ( rendererType == "singlebandgray" )
{
QgsSingleBandGrayRenderer* gr = dynamic_cast<QgsSingleBandGrayRenderer*>( mRenderer );
if ( gr )
{
int grayBand = gr->grayBand();
if ( grayBand == -1 )
{
return;
}
QgsRasterDataProvider::DataType dataType = ( QgsRasterDataProvider::DataType )mDataProvider->dataType( grayBand );
QgsContrastEnhancement* ce = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )dataType );
ce->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
ce->setMinimumValue( mDataProvider->minimumValue( grayBand ) );
ce->setMaximumValue( mDataProvider->maximumValue( grayBand ) );
gr->setContrastEnhancement( ce );
}
}
else if ( rendererType == "multibandcolor" )
{
QgsMultiBandColorRenderer* cr = dynamic_cast<QgsMultiBandColorRenderer*>( mRenderer );
if ( cr )
{
//red enhancement
int redBand = cr->redBand();
if ( redBand != -1 )
{
QgsRasterDataProvider::DataType redType = ( QgsRasterDataProvider::DataType )mDataProvider->dataType( redBand );
QgsContrastEnhancement* redEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )redType );
redEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
redEnhancement->setMinimumValue( mDataProvider->minimumValue( redBand ) );
redEnhancement->setMaximumValue( mDataProvider->maximumValue( redBand ) );
cr->setRedContrastEnhancement( redEnhancement );
}

//green enhancement
int greenBand = cr->greenBand();
if ( greenBand != -1 )
{
QgsRasterDataProvider::DataType greenType = ( QgsRasterDataProvider::DataType )mDataProvider->dataType( cr->greenBand() );
QgsContrastEnhancement* greenEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )greenType );
greenEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
greenEnhancement->setMinimumValue( mDataProvider->minimumValue( greenBand ) );
greenEnhancement->setMaximumValue( mDataProvider->maximumValue( greenBand ) );
cr->setGreenContrastEnhancement( greenEnhancement );
}

//blue enhancement
int blueBand = cr->blueBand();
if ( blueBand != -1 )
{
QgsRasterDataProvider::DataType blueType = ( QgsRasterDataProvider::DataType )mDataProvider->dataType( cr->blueBand() );
QgsContrastEnhancement* blueEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )blueType );
blueEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
blueEnhancement->setMinimumValue( mDataProvider->minimumValue( blueBand ) );
blueEnhancement->setMaximumValue( mDataProvider->maximumValue( blueBand ) );
cr->setBlueContrastEnhancement( blueEnhancement );
}
}
}
mContrastEnhancementAlgorithm = theAlgorithm;
}

void QgsRasterLayer::setContrastEnhancementAlgorithm( QString theAlgorithm, bool theGenerateLookupTableFlag )
@@ -140,6 +140,8 @@ bool QgsRenderChecker::runTest( QString theTestName,
QImage myImage( myExpectedImage.width(),
myExpectedImage.height(),
QImage::Format_RGB32 );
myImage.setDotsPerMeterX( myExpectedImage.dotsPerMeterX() );
myImage.setDotsPerMeterY( myExpectedImage.dotsPerMeterY() );
myImage.fill( qRgb( 152, 219, 249 ) );
QPainter myPainter( &myImage );
myPainter.setRenderHint( QPainter::Antialiasing );

0 comments on commit 6022143

Please sign in to comment.
You can’t perform that action at this time.