Für alle die sich mit AlphaBlend rumärgern müssen, hier noch die Änderung am urspünglichen Code:
Delphi-Quellcode:
var
Alpha: word;
{...}
for Col in [0 .. Buffer.Width - 1] do
begin
BufferPixel := @BufferScanline[Col];
MaskPixel := @MaskScanline[Col];
Alpha := (MaskPixel.rgbtRed + MaskPixel.rgbtGreen + MaskPixel.rgbtBlue) div 3;
// premultiplied alpha, red, green and blue channel
BufferPixel.rgbRed := (BufferPixel.rgbRed * Alpha) shr 8;
BufferPixel.rgbGreen := (BufferPixel.rgbGreen * Alpha) shr 8;
BufferPixel.rgbBlue := (BufferPixel.rgbBlue * Alpha) shr 8;
BufferPixel.rgbReserved := Alpha;
end;