Skip to content
Permalink
Browse files

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
  • Loading branch information
mhugent
mhugent committed Mar 13, 2009
1 parent 9384f60 commit 91b7016a40ed4753c654f26b6257cbf5ef72d0dd
Showing with 22 additions and 7 deletions.
  1. +20 −6 src/core/raster/qgsrasterlayer.cpp
  2. +2 −1 src/providers/wms/qgswmsprovider.cpp
@@ -1535,15 +1535,24 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
//Set the transparency for the whole layer
//QImage::setAlphaChannel does not work quite as expected so set each pixel individually
//Currently this is only done for WMS images, which should be small enough not to impact performance
int myWidth = image->width();
int myHeight = image->height();
QRgb myRgb;
for( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )

if(mTransparencyLevel != 255) //improve performance if layer transparency not altered
{
for( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
QImage* transparentImageCopy = new QImage(*image); //copy image if there is user transparency
image = transparentImageCopy;
int myWidth = image->width();
int myHeight = image->height();
QRgb myRgb;
int newTransparency;
for ( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
{
for ( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
{
myRgb = image->pixel( myWidthRunner, myHeightRunner );
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), mTransparencyLevel ) );
//combine transparency from WMS and layer transparency
newTransparency = (double) mTransparencyLevel / 255.0 * (double)(qAlpha(myRgb));
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), newTransparency ));
}
}
}

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

if(mTransparencyLevel != 255)
{
delete image;
}

}
else
{
@@ -2071,6 +2071,7 @@ QString QgsWmsProvider::metadata()
myMetadataQString += "</td></tr>";

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

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

0 comments on commit 91b7016

Please sign in to comment.
You can’t perform that action at this time.