Skip to content

Commit 6a64213

Browse files
author
mhugent
committedMar 4, 2009
For WMS layers: combine the transparency of WMS and the layer transparency
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10262 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 26c5b1c commit 6a64213

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed
 

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,16 +1535,23 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
15351535
//Set the transparency for the whole layer
15361536
//QImage::setAlphaChannel does not work quite as expected so set each pixel individually
15371537
//Currently this is only done for WMS images, which should be small enough not to impact performance
1538-
int myWidth = image->width();
1539-
int myHeight = image->height();
1540-
QRgb myRgb;
1541-
for ( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
1538+
1539+
if(mTransparencyLevel != 255) //improve performance if layer transparency not altered
15421540
{
1543-
for ( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
1544-
{
1545-
myRgb = image->pixel( myWidthRunner, myHeightRunner );
1546-
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), mTransparencyLevel ) );
1547-
}
1541+
int myWidth = image->width();
1542+
int myHeight = image->height();
1543+
QRgb myRgb;
1544+
int newTransparency;
1545+
for ( int myHeightRunner = 0; myHeightRunner < myHeight; myHeightRunner++ )
1546+
{
1547+
for ( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
1548+
{
1549+
myRgb = image->pixel( myWidthRunner, myHeightRunner );
1550+
//combine transparency from WMS and layer transparency
1551+
newTransparency = (double) mTransparencyLevel / 255.0 * (double)(qAlpha(myRgb));
1552+
image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), newTransparency ));
1553+
}
1554+
}
15481555
}
15491556

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

0 commit comments

Comments
 (0)
Please sign in to comment.