Skip to content
Permalink
Browse files

Faster multiband color renderer in some circumstances

(cherry picked from commit c0d2924)
  • Loading branch information
nyalldawson committed Dec 21, 2020
1 parent d9d5f20 commit 3f091dd3fb7d96f93989ccdd2f3c3775d01da12f
Showing with 30 additions and 9 deletions.
  1. +30 −9 src/core/raster/qgsmultibandcolorrenderer.cpp
@@ -266,23 +266,44 @@ QgsRasterBlock *QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons
{
if ( fastDraw ) //fast rendering if no transparency, stretching, color inversion, etc.
{
if ( redBlock->isNoData( i ) ||
greenBlock->isNoData( i ) ||
blueBlock->isNoData( i ) )
if ( hasByteRgb )
{
outputBlock->setColor( i, myDefaultColor );
if ( redBlock->isNoData( i ) ||
greenBlock->isNoData( i ) ||
blueBlock->isNoData( i ) )
{
outputBlock->setColor( i, myDefaultColor );
}
else
{
outputBlockColorData[i] = qRgb( redData[i], greenData[i], blueData[i] );
}
}
else
{
if ( hasByteRgb )
bool redIsNoData = false;
bool greenIsNoData = false;
bool blueIsNoData = false;
int redVal = 0;
int greenVal = 0;
int blueVal = 0;

redVal = redBlock->valueAndNoData( i, redIsNoData );
// as soon as any channel has a no data value, don't do any more work -- the result will
// always be the nodata color!
if ( !redIsNoData )
greenVal = greenBlock->valueAndNoData( i, greenIsNoData );
if ( !redIsNoData && !greenIsNoData )
blueVal = blueBlock->valueAndNoData( i, blueIsNoData );

if ( redIsNoData ||
greenIsNoData ||
blueIsNoData )
{
outputBlockColorData[i] = qRgb( redData[i], greenData[i], blueData[i] );
outputBlock->setColor( i, myDefaultColor );
}
else
{
int redVal = static_cast<int>( redBlock->value( i ) );
int greenVal = static_cast<int>( greenBlock->value( i ) );
int blueVal = static_cast<int>( blueBlock->value( i ) );
outputBlockColorData[i] = qRgb( redVal, greenVal, blueVal );
}
}

0 comments on commit 3f091dd

Please sign in to comment.
You can’t perform that action at this time.