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

git-svn-id: http://svn.osgeo.org/qgis/trunk@10262 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2009-03-04 13:26:38 +00:00
parent 2cce14135e
commit 73715607eb

View File

@ -1535,15 +1535,22 @@ 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
if(mTransparencyLevel != 255) //improve performance if layer transparency not altered
{
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 ));
}
}
}