Skip to content

Commit 91b7016

Browse files
author
mhugent
committed
Backport of wms transparency and properties fixes
git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@10276 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9384f60 commit 91b7016

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/core/raster/qgsrasterlayer.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,24 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
15351535
//Set the transparency for the whole layer
15361536
//QImage::setAlphaChannel does not work quite as expected so set each pixel individually
15371537
//Currently this is only done for WMS images, which should be small enough not to impact performance
1538-
int myWidth = image->width();
1539-
int myHeight = image->height();
1540-
QRgb myRgb;
1541-
for( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
1538+
1539+
if(mTransparencyLevel != 255) //improve performance if layer transparency not altered
15421540
{
1543-
for( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
1541+
QImage* transparentImageCopy = new QImage(*image); //copy image if there is user transparency
1542+
image = transparentImageCopy;
1543+
int myWidth = image->width();
1544+
int myHeight = image->height();
1545+
QRgb myRgb;
1546+
int newTransparency;
1547+
for ( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
15441548
{
1549+
for ( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
1550+
{
15451551
myRgb = image->pixel( myWidthRunner, myHeightRunner );
1546-
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), mTransparencyLevel ) );
1552+
//combine transparency from WMS and layer transparency
1553+
newTransparency = (double) mTransparencyLevel / 255.0 * (double)(qAlpha(myRgb));
1554+
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), newTransparency ));
1555+
}
15471556
}
15481557
}
15491558

@@ -1562,6 +1571,11 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
15621571
),
15631572
*image );
15641573

1574+
if(mTransparencyLevel != 255)
1575+
{
1576+
delete image;
1577+
}
1578+
15651579
}
15661580
else
15671581
{

src/providers/wms/qgswmsprovider.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,7 @@ QString QgsWmsProvider::metadata()
20712071
myMetadataQString += "</td></tr>";
20722072

20732073
// Layer Coordinate Reference Systems
2074+
/* MH: disable this as it causes performance problems if the server supports many CRS (e.g. QGIS mapserver)
20742075
for ( uint j = 0; j < layersSupported[i].crs.size(); j++ )
20752076
{
20762077
myMetadataQString += "<tr><td bgcolor=\"gray\">";
@@ -2079,7 +2080,7 @@ QString QgsWmsProvider::metadata()
20792080
myMetadataQString += "<td bgcolor=\"gray\">";
20802081
myMetadataQString += layersSupported[i].crs[j];
20812082
myMetadataQString += "</td></tr>";
2082-
}
2083+
}*/
20832084

20842085
// Layer Styles
20852086
for ( uint j = 0; j < layersSupported[i].style.size(); j++ )

0 commit comments

Comments
 (0)