Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix/reintroduce wms layer transparency
git-svn-id: http://svn.osgeo.org/qgis/trunk@15473 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 14, 2011
1 parent 94fc6a0 commit bf58ae2
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit bf58ae2

Please sign in to comment.