Skip to content

Commit

Permalink
fix #3626
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15520 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 16, 2011
1 parent 8930c0d commit 5f9a3da
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -3622,11 +3622,9 @@ void QgsRasterLayer::drawSingleBandColorData( QPainter * theQPainter, QgsRasterV
QRgb* imageScanLine = 0;
void* rasterScanLine = 0;

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

while ( imageBuffer.nextScanLine( &imageScanLine, &rasterScanLine ) )
{
if ( mTransparencyLevel == 0 )
if ( mTransparencyLevel == 255 )
{
int size = theRasterViewPort->drawableAreaXDim * 4;
memcpy( imageScanLine, rasterScanLine, size );
Expand All @@ -3636,26 +3634,8 @@ void QgsRasterLayer::drawSingleBandColorData( QPainter * theQPainter, QgsRasterV
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 );
QRgb c( *p++ );
imageScanLine[ i ] = qRgba( qRed( c ), qGreen( c ), qBlue( c ), mTransparencyLevel );
}
}
}
Expand Down

0 comments on commit 5f9a3da

Please sign in to comment.