Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
-merged revision 10146 into branch
- Loading branch information
Showing
with
17 additions
and
5 deletions.
-
+13
−3
src/core/raster/qgsrasterlayer.cpp
-
+4
−2
src/providers/wms/qgswmsprovider.cpp
|
@@ -1508,9 +1508,19 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext ) |
|
|
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 |
|
|
|
@@ -514,8 +514,10 @@ QImage* QgsWmsProvider::draw( QgsRectangle const & viewExtent, int pixelWidth, |
|
|
{ |
|
|
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; |
|
|