Skip to content

Commit 46b012f

Browse files
mhugentrldhont
authored andcommittedDec 12, 2016
WMS 1.3.0 compliance: support BGCOLOR parameter
1 parent c749d98 commit 46b012f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎src/server/qgswmsserver.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,19 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
19691969
//transparent parameter
19701970
bool transparent = mParameters.value( "TRANSPARENT" ).compare( "true", Qt::CaseInsensitive ) == 0;
19711971

1972+
//background color
1973+
QString bgColorString = mParameters.value( "BGCOLOR" );
1974+
if ( bgColorString.startsWith( "0x", Qt::CaseInsensitive ) );
1975+
{
1976+
bgColorString.replace( 0, 2, "#" );
1977+
}
1978+
QColor backgroundColor;
1979+
backgroundColor.setNamedColor( bgColorString );
1980+
if ( !backgroundColor.isValid() )
1981+
{
1982+
backgroundColor = QColor( Qt::white );
1983+
}
1984+
19721985
//use alpha channel only if necessary because it slows down performance
19731986
if ( transparent && !jpeg )
19741987
{
@@ -1978,7 +1991,7 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
19781991
else
19791992
{
19801993
theImage = new QImage( width, height, QImage::Format_RGB32 );
1981-
theImage->fill( qRgb( 255, 255, 255 ) );
1994+
theImage->fill( backgroundColor );
19821995
}
19831996

19841997
if ( !theImage )

0 commit comments

Comments
 (0)
Please sign in to comment.