Skip to content

Commit

Permalink
Optimization in writing raster values in paletted raster renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 7, 2012
1 parent 8dc0135 commit 2da5cc9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/core/raster/qgspalettedrasterrenderer.cpp
Expand Up @@ -146,6 +146,8 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
return outputBlock;
}

unsigned int* outputData = ( unsigned int* )( outputBlock->data() );

for ( size_t i = 0; i < ( size_t )width*height; i++ )
{
int val = ( int ) inputBlock->value( i );
Expand All @@ -156,14 +158,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
}
if ( !hasTransparency )
{
if ( val < 0 || val > mNColors )
{
outputBlock->setColor( i, myDefaultColor );
}
else
{
outputBlock->setColor( i, mColors[ val ].rgba() );
}
outputData[i] = mColors[ val ].rgba();
}
else
{
Expand All @@ -177,8 +172,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
currentOpacity *= alphaBlock->value( i ) / 255.0;
}
QColor& currentColor = mColors[val];

outputBlock->setColor( i, qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 ) );
outputData[i] = qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 );
}
}

Expand Down

0 comments on commit 2da5cc9

Please sign in to comment.