Skip to content

Commit 4d5cc5a

Browse files
mhugentrldhont
authored andcommitted
WMS 1.3.0 compliance: support BGCOLOR parameter
1 parent 6eba1ce commit 4d5cc5a

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
@@ -1962,6 +1962,19 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
19621962
//transparent parameter
19631963
bool transparent = mParameters.value( "TRANSPARENT" ).compare( "true", Qt::CaseInsensitive ) == 0;
19641964

1965+
//background color
1966+
QString bgColorString = mParameters.value( "BGCOLOR" );
1967+
if ( bgColorString.startsWith( "0x", Qt::CaseInsensitive ) );
1968+
{
1969+
bgColorString.replace( 0, 2, "#" );
1970+
}
1971+
QColor backgroundColor;
1972+
backgroundColor.setNamedColor( bgColorString );
1973+
if ( !backgroundColor.isValid() )
1974+
{
1975+
backgroundColor = QColor( Qt::white );
1976+
}
1977+
19651978
//use alpha channel only if necessary because it slows down performance
19661979
if ( transparent && !jpeg )
19671980
{
@@ -1971,7 +1984,7 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
19711984
else
19721985
{
19731986
theImage = new QImage( width, height, QImage::Format_RGB32 );
1974-
theImage->fill( qRgb( 255, 255, 255 ) );
1987+
theImage->fill( backgroundColor );
19751988
}
19761989

19771990
if ( !theImage )

0 commit comments

Comments
 (0)