16
16
***************************************************************************/
17
17
18
18
#include " qgssinglebandcolordatarenderer.h"
19
+ #include " qgsrasterviewport.h"
19
20
#include < QImage>
20
21
21
22
QgsSingleBandColorDataRenderer::QgsSingleBandColorDataRenderer ( QgsRasterDataProvider* provider, int band, QgsRasterResampler* resampler ):
@@ -41,16 +42,29 @@ void QgsSingleBandColorDataRenderer::draw( QPainter* p, QgsRasterViewPort* viewP
41
42
int topLeftCol, topLeftRow, nCols, nRows, currentRasterPos;
42
43
void * rasterData;
43
44
45
+ bool hasTransparency = usesTransparency ( viewPort->mSrcCRS , viewPort->mDestCRS );
46
+
44
47
while ( readNextRasterPart ( mBand , viewPort, nCols, nRows, &rasterData, topLeftCol, topLeftRow ) )
45
48
{
46
49
currentRasterPos = 0 ;
47
- QImage img ( nCols, nRows, QImage::Format_ARGB32_Premultiplied );
50
+ QImage img ( nCols, nRows, QImage::Format_ARGB32 );
51
+ uchar* scanLine = 0 ;
48
52
for ( int i = 0 ; i < nRows; ++i )
49
53
{
50
- memcpy ( img.scanLine ( i ), &((( uint* )rasterData )[currentRasterPos] ), nCols * 4 );
51
- for ( int j = 0 ; j < nCols; ++j )
54
+ scanLine = img.scanLine ( i );
55
+ if ( !hasTransparency )
56
+ {
57
+ memcpy ( scanLine, &((( uint* )rasterData )[currentRasterPos] ), nCols * 4 );
58
+ currentRasterPos += nCols;
59
+ }
60
+ else
52
61
{
53
- ++currentRasterPos;
62
+ for ( int j = 0 ; j < nCols; ++j )
63
+ {
64
+ QRgb c ( ( (uint*)(rasterData) )[currentRasterPos] );
65
+ scanLine[i] = qRgba ( qRed ( c ), qGreen ( c ), qBlue ( c ), 255 );
66
+ ++currentRasterPos;
67
+ }
54
68
}
55
69
}
56
70
0 commit comments