Skip to content

Commit

Permalink
More improvements for single band color data
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jan 5, 2012
1 parent 5ee5a17 commit 4809f06
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/core/raster/qgssinglebandcolordatarenderer.cpp
Expand Up @@ -16,6 +16,7 @@
***************************************************************************/

#include "qgssinglebandcolordatarenderer.h"
#include "qgsrasterviewport.h"
#include <QImage>

QgsSingleBandColorDataRenderer::QgsSingleBandColorDataRenderer( QgsRasterDataProvider* provider, int band, QgsRasterResampler* resampler ):
Expand All @@ -41,16 +42,29 @@ void QgsSingleBandColorDataRenderer::draw( QPainter* p, QgsRasterViewPort* viewP
int topLeftCol, topLeftRow, nCols, nRows, currentRasterPos;
void* rasterData;

bool hasTransparency = usesTransparency( viewPort->mSrcCRS, viewPort->mDestCRS );

while ( readNextRasterPart( mBand, viewPort, nCols, nRows, &rasterData, topLeftCol, topLeftRow ) )
{
currentRasterPos = 0;
QImage img( nCols, nRows, QImage::Format_ARGB32_Premultiplied );
QImage img( nCols, nRows, QImage::Format_ARGB32 );
uchar* scanLine = 0;
for ( int i = 0; i < nRows; ++i )
{
memcpy( img.scanLine( i ), &((( uint* )rasterData )[currentRasterPos] ), nCols * 4 );
for ( int j = 0; j < nCols; ++j )
scanLine = img.scanLine( i );
if( !hasTransparency )
{
memcpy( scanLine, &((( uint* )rasterData )[currentRasterPos] ), nCols * 4 );
currentRasterPos += nCols;
}
else
{
++currentRasterPos;
for ( int j = 0; j < nCols; ++j )
{
QRgb c( ( (uint*)(rasterData) )[currentRasterPos] );
scanLine[i] = qRgba( qRed( c ), qGreen( c ), qBlue( c ), 255 );
++currentRasterPos;
}
}
}

Expand Down

0 comments on commit 4809f06

Please sign in to comment.