@@ -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
36333664void QgsRasterLayer::drawMultiBandColor ( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,
0 commit comments