Skip to content

Commit bf58ae2

Browse files
author
jef
committedMar 14, 2011
fix/reintroduce wms layer transparency
git-svn-id: http://svn.osgeo.org/qgis/trunk@15473 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 94fc6a0 commit bf58ae2

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed
 

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,12 +3622,43 @@ void QgsRasterLayer::drawSingleBandColorData( QPainter * theQPainter, QgsRasterV
36223622
QRgb* imageScanLine = 0;
36233623
void* rasterScanLine = 0;
36243624

3625+
QRgb myDefaultColor = qRgba( 255, 255, 255, 0 );
3626+
36253627
while ( imageBuffer.nextScanLine( &imageScanLine, &rasterScanLine ) )
36263628
{
3627-
int size = theRasterViewPort->drawableAreaXDim * 4;
3628-
memcpy( imageScanLine, rasterScanLine, size );
3629-
}
3629+
if ( mTransparencyLevel == 0 )
3630+
{
3631+
int size = theRasterViewPort->drawableAreaXDim * 4;
3632+
memcpy( imageScanLine, rasterScanLine, size );
3633+
}
3634+
else
3635+
{
3636+
uint *p = ( uint* ) rasterScanLine;
3637+
for ( int i = 0; i < theRasterViewPort->drawableAreaXDim; ++i )
3638+
{
3639+
uint v = *p++;
3640+
int myRedValue = ( v & 0xff0000 ) >> 16;
3641+
int myGreenValue = ( v & 0xff00 ) >> 8;
3642+
int myBlueValue = ( v & 0xff );
36303643

3644+
int myAlphaValue = mRasterTransparency.alphaValue( myRedValue, myGreenValue, myBlueValue, mTransparencyLevel );
3645+
if ( 0 == myAlphaValue )
3646+
{
3647+
imageScanLine[ i ] = myDefaultColor;
3648+
continue;
3649+
}
3650+
3651+
if ( mInvertColor )
3652+
{
3653+
myRedValue = 255 - myRedValue;
3654+
myGreenValue = 255 - myGreenValue;
3655+
myBlueValue = 255 - myBlueValue;
3656+
}
3657+
3658+
imageScanLine[ i ] = qRgba( myRedValue, myGreenValue, myBlueValue, myAlphaValue );
3659+
}
3660+
}
3661+
}
36313662
}
36323663

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

0 commit comments

Comments
 (0)
Please sign in to comment.