Skip to content

Commit

Permalink
Fix hue/saturation changes for rasters causing debug noise when raste…
Browse files Browse the repository at this point in the history
…r contains transparent pixels
  • Loading branch information
nyalldawson committed Jan 14, 2014
1 parent a31ebb4 commit 4ba3e7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/raster/qgsbrightnesscontrastfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ int QgsBrightnessContrastFilter::adjustColorComponent( int colorComponent, int a
// Opaque pixel, do simpler math
return qBound( 0, ( int )(((((( colorComponent / 255.0 ) - 0.5 ) * contrastFactor ) + 0.5 ) * 255 ) + brightness ), 255 );
}
else if ( alpha == 0 )
{
// Totally transparent pixel
return 0;
}
else
{
// Semi-transparent pixel. We need to adjust the math since we are using QGis::ARGB32_Premultiplied
Expand Down
7 changes: 7 additions & 0 deletions src/core/raster/qgshuesaturationfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ QgsRasterBlock * QgsHueSaturationFilter::block( int bandNo, QgsRectangle const
// Alpha must be taken from QRgb, since conversion from QRgb->QColor loses alpha
alpha = qAlpha( myRgb );

if ( alpha == 0 )
{
// totally transparent, no changes required
outputBlock->setColor( i, myRgb );
continue;
}

// Get rgb for color
myColor.getRgb( &r, &g, &b );
if ( alpha != 255 )
Expand Down

0 comments on commit 4ba3e7c

Please sign in to comment.