Skip to content
Permalink
Browse files

Faster multiband color renderer in some circumstances

  • Loading branch information
nyalldawson committed Dec 18, 2020
1 parent e488a57 commit c0d2924587d2c70665fdecf24f164a3ec889b8b5
Showing with 30 additions and 9 deletions.
  1. +30 −9 src/core/raster/qgsmultibandcolorrenderer.cpp
@@ -267,23 +267,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 c0d2924

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