Showing with 9 additions and 2 deletions.
  1. +8 −1 src/mapserver/qgshttprequesthandler.cpp
  2. +1 −1 src/mapserver/qgswmsserver.cpp
9 changes: 8 additions & 1 deletion src/mapserver/qgshttprequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
if ( img )
{
bool png8Bit = ( mFormat.compare( "image/png; mode=8bit", Qt::CaseInsensitive ) == 0 );
if ( mFormat != "PNG" && mFormat != "JPG" && !png8Bit )
bool png1Bit = ( mFormat.compare( "image/png; mode=1bit", Qt::CaseInsensitive ) == 0 );
if ( mFormat != "PNG" && mFormat != "JPG" && !png8Bit && !png1Bit )
{
QgsDebugMsg( "service exception - incorrect image format requested..." );
sendServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormat + "' is not supported in the GetMap request" ) );
Expand All @@ -117,6 +118,12 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
Qt::ThresholdAlphaDither | Qt::NoOpaqueDetection );
palettedImg.save( &buffer, "PNG", -1 );
}
else if ( png1Bit )
{
QImage palettedImg = img->convertToFormat( QImage::Format_Mono, Qt::MonoOnly | Qt::ThresholdDither |
Qt::ThresholdAlphaDither | Qt::NoOpaqueDetection );
palettedImg.save( &buffer, "PNG", -1 );
}
else
{
img->save( &buffer, mFormat.toLocal8Bit().data(), -1 );
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf

//wms:GetMap
elem = doc.createElement( "GetMap"/*wms:GetMap*/ );
appendFormats( doc, elem, QStringList() << "image/jpeg" << "image/png" << "image/png; mode=8bit" );
appendFormats( doc, elem, QStringList() << "image/jpeg" << "image/png" << "image/png; mode=8bit" << "image/png; mode=1bit" );
elem.appendChild( dcpTypeElement.cloneNode().toElement() ); //this is the same as for 'GetCapabilities'
requestElement.appendChild( elem );

Expand Down