@@ -3622,12 +3622,43 @@ void QgsRasterLayer::drawSingleBandColorData( QPainter * theQPainter, QgsRasterV
3622
3622
QRgb* imageScanLine = 0 ;
3623
3623
void * rasterScanLine = 0 ;
3624
3624
3625
+ QRgb myDefaultColor = qRgba ( 255 , 255 , 255 , 0 );
3626
+
3625
3627
while ( imageBuffer.nextScanLine ( &imageScanLine, &rasterScanLine ) )
3626
3628
{
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 );
3630
3643
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
+ }
3631
3662
}
3632
3663
3633
3664
void QgsRasterLayer::drawMultiBandColor ( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,
0 commit comments