Skip to content
Permalink
Browse files
Optimization in writing raster values in paletted raster renderer
  • Loading branch information
mhugent committed Dec 7, 2012
1 parent 8dc0135 commit 2da5cc95b75685c40186efcf82f851062fefa782
Showing with 4 additions and 10 deletions.
  1. +4 −10 src/core/raster/qgspalettedrasterrenderer.cpp
@@ -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 );
@@ -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
{
@@ -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 );
}
}

0 comments on commit 2da5cc9

Please sign in to comment.