[QGIS Commit] r10171 - in branches/Version-1_0/src: core/raster
providers/wms
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Feb 14 20:48:08 EST 2009
Author: ersts
Date: 2009-02-14 20:48:08 -0500 (Sat, 14 Feb 2009)
New Revision: 10171
Modified:
branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp
branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp
Log:
-merged revision 10146 into branch
-Fixes ticket #1533
Modified: branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp 2009-02-14 19:43:37 UTC (rev 10170)
+++ branches/Version-1_0/src/core/raster/qgsrasterlayer.cpp 2009-02-15 01:48:08 UTC (rev 10171)
@@ -1508,9 +1508,19 @@
QgsDebugMsg( QString( "(int)origin y: %1" ).arg( static_cast<int>( myRasterViewPort->topLeftPoint.y() ) ) );
//Set the transparency for the whole layer
- QImage myAlphaChannel( image->width(), image->height(), QImage::Format_Indexed8 );
- myAlphaChannel.fill(( uint ) mTransparencyLevel );
- image->setAlphaChannel( myAlphaChannel );
+ //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++ )
+ {
+ for( int myWidthRunner = 0; myWidthRunner < myWidth; myWidthRunner++ )
+ {
+ myRgb = image->pixel( myWidthRunner, myHeightRunner );
+ image->setPixel( myWidthRunner, myHeightRunner, qRgba( qRed( myRgb ), qGreen( myRgb ), qBlue( myRgb ), mTransparencyLevel ) );
+ }
+ }
// Since GDAL's RasterIO can't handle floating point, we have to round to
// the nearest pixel. Add 0.5 to get rounding instead of truncation
Modified: branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp 2009-02-14 19:43:37 UTC (rev 10170)
+++ branches/Version-1_0/src/providers/wms/qgswmsprovider.cpp 2009-02-15 01:48:08 UTC (rev 10171)
@@ -514,9 +514,11 @@
{
delete cachedImage;
}
- cachedImage = new QImage();
- *cachedImage = QImage::fromData( imagesource );
+ //Create a local image from source then convert it to RGBA, so we can set the transparency later
+ QImage myLocalImage = QImage::fromData( imagesource );
+ cachedImage = new QImage( myLocalImage.convertToFormat( QImage::Format_ARGB32 ) );
+
// Remember settings for useful caching next time.
cachedViewExtent = viewExtent;
cachedPixelWidth = pixelWidth;
More information about the QGIS-commit
mailing list