Skip to content

Commit ae64430

Browse files
committed
WMS 1.3.0 compliance: support BGCOLOR parameter
1 parent 63f496c commit ae64430

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/server/qgswmsserver.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,19 @@ QImage* QgsWmsServer::createImage( int width, int height ) const
19781978
//transparent parameter
19791979
bool transparent = mParameters.value( QStringLiteral( "TRANSPARENT" ) ).compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0;
19801980

1981+
//background color
1982+
QString bgColorString = mParameters.value( "BGCOLOR" );
1983+
if ( bgColorString.startsWith( "0x", Qt::CaseInsensitive ) );
1984+
{
1985+
bgColorString.replace( 0, 2, "#" );
1986+
}
1987+
QColor backgroundColor;
1988+
backgroundColor.setNamedColor( bgColorString );
1989+
if ( !backgroundColor.isValid() )
1990+
{
1991+
backgroundColor = QColor( Qt::white );
1992+
}
1993+
19811994
//use alpha channel only if necessary because it slows down performance
19821995
if ( transparent && !jpeg )
19831996
{
@@ -1987,7 +2000,7 @@ QImage* QgsWmsServer::createImage( int width, int height ) const
19872000
else
19882001
{
19892002
theImage = new QImage( width, height, QImage::Format_RGB32 );
1990-
theImage->fill( qRgb( 255, 255, 255 ) );
2003+
theImage->fill( backgroundColor );
19912004
}
19922005

19932006
if ( !theImage )

0 commit comments

Comments
 (0)