mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-12 00:02:25 -04:00
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:
parent
2cce14135e
commit
73715607eb
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user