Correct alpha blending in PDF plot
We fake the alpha channel by pre-multiplying but we forgot to account
for the downscaling of the input channel value in addition to correcting
the alpha * white. This led to clipping when the values overflowed
Fixes https://gitlab.com/kicad/code/kicad/issues/14238
(cherry picked from commit d405fff1d8
)
This commit is contained in:
parent
d5bf831f60
commit
bff2f53996
|
@ -513,10 +513,11 @@ void PDF_PLOTTER::PlotImage( const wxImage& aImage, const VECTOR2I& aPos, double
|
|||
|
||||
if( alpha < 0xFF )
|
||||
{
|
||||
float a = 1.0 - ( (float) alpha / 255.0 );
|
||||
r = ( int )( r + ( a * 0xFF ) ) & 0xFF;
|
||||
g = ( int )( g + ( a * 0xFF ) ) & 0xFF;
|
||||
b = ( int )( b + ( a * 0xFF ) ) & 0xFF;
|
||||
float d = alpha / 255.0;
|
||||
float a = 1.0 - d;
|
||||
r = std::min( KiROUND( r * d + ( a * 0xFF ) ), 0xFF );
|
||||
g = std::min( KiROUND( g * d + ( a * 0xFF ) ), 0xFF );
|
||||
b = std::min( KiROUND( b * d + ( a * 0xFF ) ), 0xFF );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue