[pascal]D.R := B.R + (S.R - B.R) * S.A div 255;
D.G := B.G + (S.R - B.G) * S.A div 255;
D.B := B.B + (S.R - B.B) * S.A div 255;
[/pascal]
This code definitely should work. Division is last operation there so there will not be any math errors. Using function to round float to int makes it just slower.