Skip to content

Commit 12fe4fa

Browse files
committed
Add image/png; mode=16bit as a supported format
1 parent 91419ba commit 12fe4fa

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/mapserver/qgshttprequesthandler.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
9696
QgsDebugMsg( "Sending getmap response..." );
9797
if ( img )
9898
{
99+
bool png16Bit = ( mFormatString.compare( "image/png; mode=16bit", Qt::CaseInsensitive ) == 0 );
99100
bool png8Bit = ( mFormatString.compare( "image/png; mode=8bit", Qt::CaseInsensitive ) == 0 );
100101
bool png1Bit = ( mFormatString.compare( "image/png; mode=1bit", Qt::CaseInsensitive ) == 0 );
101102
bool isBase64 = mFormatString.endsWith( ";base64", Qt::CaseInsensitive );
102-
if ( mFormat != "PNG" && mFormat != "JPG" && !png8Bit && !png1Bit )
103+
if ( mFormat != "PNG" && mFormat != "JPG" && !png16Bit && !png8Bit && !png1Bit )
103104
{
104105
QgsDebugMsg( "service exception - incorrect image format requested..." );
105106
sendServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormatString + "' is not supported in the GetMap request" ) );
@@ -119,6 +120,11 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
119120
Qt::ThresholdAlphaDither | Qt::NoOpaqueDetection );
120121
palettedImg.save( &buffer, "PNG", -1 );
121122
}
123+
else if ( png16Bit )
124+
{
125+
QImage palettedImg = img->convertToFormat( QImage::Format_ARGB4444_Premultiplied );
126+
palettedImg.save( &buffer, "PNG", -1 );
127+
}
122128
else if ( png1Bit )
123129
{
124130
QImage palettedImg = img->convertToFormat( QImage::Format_Mono, Qt::MonoOnly | Qt::ThresholdDither |

src/mapserver/qgswmsserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf
171171

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

0 commit comments

Comments
 (0)