1
0
mirror of synced 2024-09-19 17:56:09 +00:00

Fixed: BlendColors was off by 1 level for each channel (shr 8 = div 256, not div 255 dummy!)

This commit is contained in:
Mark van Renswoude 2006-03-19 14:50:39 +00:00
parent d96cbe45a4
commit 5a274c11ef

View File

@ -164,19 +164,28 @@ function BlendColors(const ABackground, AForeground: TColor;
var var
cBack: Cardinal; cBack: Cardinal;
cFore: Cardinal; cFore: Cardinal;
bBack: Byte; iBack: Integer;
iFore: Integer;
begin begin
cBack := ColorToRGB(ABackground); if AAlpha = 0 then
cFore := ColorToRGB(AForeground); Result := ABackground
bBack := 255 - AAlpha; else if AAlpha = 255 then
Result := AForeground
else
begin
cBack := ColorToRGB(ABackground);
cFore := ColorToRGB(AForeground);
iBack := 256 - AAlpha;
iFore := Succ(AAlpha);
Result := RGB(((GetRValue(cBack) * bBack) + Result := RGB(((GetRValue(cBack) * iBack) +
(GetRValue(cFore) * AAlpha)) shr 8, (GetRValue(cFore) * iFore)) shr 8,
((GetGValue(cBack) * bBack) + ((GetGValue(cBack) * iBack) +
(GetGValue(cFore) * AAlpha)) shr 8, (GetGValue(cFore) * iFore)) shr 8,
((GetBValue(cBack) * bBack) + ((GetBValue(cBack) * iBack) +
(GetBValue(cFore) * AAlpha)) shr 8); (GetBValue(cFore) * iFore)) shr 8);
end;
end; end;