Skip to content
Permalink
Browse files

For WMS layers: combine the transparency of WMS and the layer transpa…

…rency

git-svn-id: http://svn.osgeo.org/qgis/trunk@10262 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 4, 2009
1 parent 2cce141 commit 73715607eb27c08b204161c93bd6f56abc3978fc
Showing with 16 additions and 9 deletions.
  1. +16 −9 src/core/raster/qgsrasterlayer.cpp
@@ -1535,16 +1535,23 @@ 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++ )
{
myRgb = image->pixel( myWidthRunner, myHeightRunner );
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), mTransparencyLevel ) );
}
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 );
//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 ));
}
}
}

// Since GDAL's RasterIO can't handle floating point, we have to round to

0 comments on commit 7371560

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