Skip to content

Commit

Permalink
WMS 1.3.0 compliance: support BGCOLOR parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent authored and rldhont committed Dec 13, 2016
1 parent 6eba1ce commit 4d5cc5a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/server/qgswmsserver.cpp
Expand Up @@ -1962,6 +1962,19 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
//transparent parameter
bool transparent = mParameters.value( "TRANSPARENT" ).compare( "true", Qt::CaseInsensitive ) == 0;

//background color
QString bgColorString = mParameters.value( "BGCOLOR" );
if ( bgColorString.startsWith( "0x", Qt::CaseInsensitive ) );
{
bgColorString.replace( 0, 2, "#" );
}
QColor backgroundColor;
backgroundColor.setNamedColor( bgColorString );
if ( !backgroundColor.isValid() )
{
backgroundColor = QColor( Qt::white );
}

//use alpha channel only if necessary because it slows down performance
if ( transparent && !jpeg )
{
Expand All @@ -1971,7 +1984,7 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
else
{
theImage = new QImage( width, height, QImage::Format_RGB32 );
theImage->fill( qRgb( 255, 255, 255 ) );
theImage->fill( backgroundColor );
}

if ( !theImage )
Expand Down

0 comments on commit 4d5cc5a

Please sign in to comment.