Skip to content
Permalink
Browse files
Add support for 1bit PNG format to QGIS Server WMS
  • Loading branch information
schmandr committed Feb 15, 2013
1 parent c1527af commit 2e84efafc5e271cfe7fee8314662c48b5a3437cb
Showing with 9 additions and 2 deletions.
  1. +8 −1 src/mapserver/qgshttprequesthandler.cpp
  2. +1 −1 src/mapserver/qgswmsserver.cpp
@@ -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" ) );
@@ -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 );
@@ -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 );

0 comments on commit 2e84efa

Please sign in to comment.