Improve image alpha handling in PDF and PS plotters

Fixes: lp:1825276
* https://bugs.launchpad.net/kicad/+bug/1825276

(cherry picked from commit 4adf89b40b)
This commit is contained in:
Jon Evans
2019-05-27 13:06:26 -04:00
parent 3625668ff5
commit 0a6b1ea256
2 changed files with 29 additions and 0 deletions
+14
View File
@@ -709,6 +709,20 @@ void PS_PLOTTER::PlotImage( const wxImage & aImage, const wxPoint& aPos,
green = aImage.GetGreen( xx, yy) & 0xFF;
blue = aImage.GetBlue( xx, yy) & 0xFF;
// PS doesn't support alpha, so premultiply against white background
if( aImage.HasAlpha() )
{
unsigned char alpha = aImage.GetAlpha( xx, yy ) & 0xFF;
if( alpha < 0xFF )
{
float a = 1.0 - ( (float) alpha / 255.0 );
red = ( int )( red + ( a * 0xFF ) ) & 0xFF;
green = ( int )( green + ( a * 0xFF ) ) & 0xFF;
blue = ( int )( blue + ( a * 0xFF ) ) & 0xFF;
}
}
if( colorMode )
fprintf( outputFile, "%2.2X%2.2X%2.2X", red, green, blue );
else