Skip to content

Commit

Permalink
Backport of wms transparency and properties fixes
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Version-1_0@10276 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 13, 2009
1 parent 9384f60 commit 91b7016
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1535,15 +1535,24 @@ 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++ )
QImage* transparentImageCopy = new QImage(*image); //copy image if there is user transparency
image = transparentImageCopy;
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 ));
}
}
}

Expand All @@ -1562,6 +1571,11 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
),
*image );

if(mTransparencyLevel != 255)
{
delete image;
}

}
else
{
Expand Down
3 changes: 2 additions & 1 deletion src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,7 @@ QString QgsWmsProvider::metadata()
myMetadataQString += "</td></tr>";

// Layer Coordinate Reference Systems
/* MH: disable this as it causes performance problems if the server supports many CRS (e.g. QGIS mapserver)
for ( uint j = 0; j < layersSupported[i].crs.size(); j++ )
{
myMetadataQString += "<tr><td bgcolor=\"gray\">";
Expand All @@ -2079,7 +2080,7 @@ QString QgsWmsProvider::metadata()
myMetadataQString += "<td bgcolor=\"gray\">";
myMetadataQString += layersSupported[i].crs[j];
myMetadataQString += "</td></tr>";
}
}*/

// Layer Styles
for ( uint j = 0; j < layersSupported[i].style.size(); j++ )
Expand Down

0 comments on commit 91b7016

Please sign in to comment.