Skip to content
Permalink
Browse files

Fix hue/saturation changes for rasters causing debug noise when raste…

…r contains transparent pixels
  • Loading branch information
nyalldawson committed Jan 14, 2014
1 parent a31ebb4 commit 4ba3e7c8a6fa1d0e81754c23d8eb48aaae0b3d82
Showing with 12 additions and 0 deletions.
  1. +5 −0 src/core/raster/qgsbrightnesscontrastfilter.cpp
  2. +7 −0 src/core/raster/qgshuesaturationfilter.cpp
@@ -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
@@ -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 )

0 comments on commit 4ba3e7c

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