procedure FloodFill(ABmp: TBitmap; x,y: Integer; AColor: TColor; Border: TColor;
var Map: TBoolmap);
var l,i: Integer;
r,g,b: Byte;
c: TColor;
begin
if Length(Map) = 0
then
begin
SetLength(Map,Abmp.Height);
for i:= 0
to ABmp.Height-1
do
SetLength(Map[i],ABmp.Width);
end;
if Map[y,x]
then
exit;
if (ABmp.Canvas.Pixels[x,y] <> Border)
and (x >= 0)
and (x <= ABmp.Width-1)
and (y <= ABmp.Height-1)
and (y >= 0)
then
begin
l := GetRValue(ABmp.Canvas.Pixels[x,y]);
r:= cut(GetRValue(AColor)-(255-l));
g:= cut(GetGValue(AColor)-(255-l));
b:= cut(GetBValue(AColor)-(255-l));
c :=
RGB(r,g,b);
ABmp.Canvas.Pixels[x,y] := c;
Map[y,x] := true;
FloodFill(ABmp,x,y+1,AColor,Border,Map);
FloodFill(ABmp,x,y-1,AColor,Border,Map);
FloodFill(ABmp,x+1,y,AColor,Border,Map);
FloodFill(ABmp,x-1,y,AColor,Border,Map);
end;
end;