Skip to content
Permalink
Browse files

fix/reintroduce wms layer transparency

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15473 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 14, 2011
1 parent 42b2a6b commit b4e10e4429f43c5e12a45cd214eb19f6ac5e7435
Showing with 34 additions and 3 deletions.
  1. +34 −3 src/core/raster/qgsrasterlayer.cpp
@@ -3622,12 +3622,43 @@ void QgsRasterLayer::drawSingleBandColorData( QPainter * theQPainter, QgsRasterV
QRgb* imageScanLine = 0;
void* rasterScanLine = 0;

QRgb myDefaultColor = qRgba( 255, 255, 255, 0 );

while ( imageBuffer.nextScanLine( &imageScanLine, &rasterScanLine ) )
{
int size = theRasterViewPort->drawableAreaXDim * 4;
memcpy( imageScanLine, rasterScanLine, size );
}
if ( mTransparencyLevel == 0 )
{
int size = theRasterViewPort->drawableAreaXDim * 4;
memcpy( imageScanLine, rasterScanLine, size );
}
else
{
uint *p = ( uint* ) rasterScanLine;
for ( int i = 0; i < theRasterViewPort->drawableAreaXDim; ++i )
{
uint v = *p++;
int myRedValue = ( v & 0xff0000 ) >> 16;
int myGreenValue = ( v & 0xff00 ) >> 8;
int myBlueValue = ( v & 0xff );

int myAlphaValue = mRasterTransparency.alphaValue( myRedValue, myGreenValue, myBlueValue, mTransparencyLevel );
if ( 0 == myAlphaValue )
{
imageScanLine[ i ] = myDefaultColor;
continue;
}

if ( mInvertColor )
{
myRedValue = 255 - myRedValue;
myGreenValue = 255 - myGreenValue;
myBlueValue = 255 - myBlueValue;
}

imageScanLine[ i ] = qRgba( myRedValue, myGreenValue, myBlueValue, myAlphaValue );
}
}
}
}

void QgsRasterLayer::drawMultiBandColor( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,

0 comments on commit b4e10e4

Please sign in to comment.
You can’t perform that action at this time.