function GetBlendedColor(Color1, Color2: TColor; Alpha: Integer): TColor;
var
r1, g1, b1, r2, g2, b2, r, g, b: Integer;
begin
r1 := GetRValue(Color1);
g1 := GetGValue(Color1);
b1 := GetBValue(Color1);
r2 := GetRValue(Color2);
g2 := GetGValue(Color2);
b2 := GetBValue(Color2);
r := Alpha * r1 + (1 - Alpha) * r2;
g := Alpha * g1 + (1 - Alpha) * g2;
b := Alpha * b1 + (1 - Alpha) * b2;
Result :=
RGB(r, g, b);
end;
procedure InnerGlow(Color: TColor; Size, Alpha: Integer; Rect: TRect; Canvas: TCanvas);
var
CurAlpha: Extended;
CurAlphaRounded, i, x, y: Integer;
PixelColor: TColor;
begin
CurAlpha := 0;
for i := 1
to Size
do
begin
CurAlpha := Alpha / Size * i;
CurAlphaRounded := Round(CurAlpha);
for x := Rect.Left + i - 1
to Rect.Right - i + 1
do
begin
y := Rect.Top + i - 1;
PixelColor := GetPixel(Canvas.Handle, x, y);
Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded);
y := Rect.Bottom - i + 1;
PixelColor := GetPixel(Canvas.Handle, x, y);
Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded);
end;
for y := Rect.Top + i
to Rect.Bottom - i
do
begin
x := Rect.Top + i - 1;
PixelColor := GetPixel(Canvas.Handle, x, y);
Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded);
x := Rect.Bottom - i + 1;
PixelColor := GetPixel(Canvas.Handle, x, y);
Canvas.Pixels[x, y] := GetBlendedColor(Color, PixelColor, CurAlphaRounded);
end;
end;
end;