Skip to content

Commit 2da5cc9

Browse files
committedDec 7, 2012
Optimization in writing raster values in paletted raster renderer
1 parent 8dc0135 commit 2da5cc9

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed
 

‎src/core/raster/qgspalettedrasterrenderer.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
146146
return outputBlock;
147147
}
148148

149+
unsigned int* outputData = ( unsigned int* )( outputBlock->data() );
150+
149151
for ( size_t i = 0; i < ( size_t )width*height; i++ )
150152
{
151153
int val = ( int ) inputBlock->value( i );
@@ -156,14 +158,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
156158
}
157159
if ( !hasTransparency )
158160
{
159-
if ( val < 0 || val > mNColors )
160-
{
161-
outputBlock->setColor( i, myDefaultColor );
162-
}
163-
else
164-
{
165-
outputBlock->setColor( i, mColors[ val ].rgba() );
166-
}
161+
outputData[i] = mColors[ val ].rgba();
167162
}
168163
else
169164
{
@@ -177,8 +172,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
177172
currentOpacity *= alphaBlock->value( i ) / 255.0;
178173
}
179174
QColor& currentColor = mColors[val];
180-
181-
outputBlock->setColor( i, qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 ) );
175+
outputData[i] = qRgba( currentOpacity * currentColor.red(), currentOpacity * currentColor.green(), currentOpacity * currentColor.blue(), currentOpacity * 255 );
182176
}
183177
}
184178

0 commit comments

Comments
 (0)
Please sign in to comment.