Skip to content

Commit

Permalink
For WMS layers: combine the transparency of WMS and the layer transpa…
Browse files Browse the repository at this point in the history
…rency

git-svn-id: http://svn.osgeo.org/qgis/trunk@10262 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 4, 2009
1 parent 2cce141 commit 7371560
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 7371560

Please sign in to comment.