[QGIS Commit] r10276 - in branches/Version-1_0/src: core/raster
providers/wms
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Mar 13 17:31:25 EDT 2009
Author: mhugent
Date: 2009-03-13 17:31:24 -0400 (Fri, 13 Mar 2009)
New Revision: 10276
Modified:
branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp
branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp
Log:
Backport of wms transparency and properties fixes
Modified: branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp 2009-03-13 20:46:02 UTC (rev 10275)
+++ branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp 2009-03-13 21:31:24 UTC (rev 10276)
@@ -1535,15 +1535,24 @@
//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 ));
+ }
}
}
@@ -1562,6 +1571,11 @@
),
*image );
+ if(mTransparencyLevel != 255)
+ {
+ delete image;
+ }
+
}
else
{
Modified: branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp 2009-03-13 20:46:02 UTC (rev 10275)
+++ branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp 2009-03-13 21:31:24 UTC (rev 10276)
@@ -2071,6 +2071,7 @@
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\">";
@@ -2079,7 +2080,7 @@
myMetadataQString += "<td bgcolor=\"gray\">";
myMetadataQString += layersSupported[i].crs[j];
myMetadataQString += "</td></tr>";
- }
+ }*/
// Layer Styles
for ( uint j = 0; j < layersSupported[i].style.size(); j++ )
More information about the QGIS-commit
mailing list