Registriert seit: 8. Feb 2006
Ort: Slovenia
90 Beiträge
Delphi 7 Personal
|
Backtrack FloodFill algoritm
19. Mär 2006, 17:19
hi there, iam trying to make a flood fill alghoritm (i created one using backtracking),the alghoritm is good, but the problem is that it stacks overflow by large inputs (what can i do ) i have 2048MB of Ram why i can use only a few kb for programmes...how can i tell delphi that it should use stack up to maximum?
Delphi-Quellcode:
procedure TCore.SpillDraw(iX,iY:integer);
var top_ln,bottom_ln,Mode:integer;
replace_Char:string;
procedure BacktrackFill(x,y:integer;fill_char,repl_char:char);
begin
if not(Edit.Cells[x,y]=fill_char) and (Edit.Cells[x,y]=repl_char) and (x<=Edit.ColCount) and (x>=0) and (y<=Edit.RowCount) and (y>=0) then
begin
//showmessage('test');
Edit.Cells[x,y]:=fill_char;
BacktrackFill(x,y,fill_char,repl_char);
BacktrackFill(x-1,y,fill_char,repl_char);
BacktrackFill(x+1,y,fill_char,repl_char);
BacktrackFill(x,y-1,fill_char,repl_char);
BacktrackFill(x,y+1,fill_char,repl_char);
end;
end;
begin
if (Edit.MouseCoord(ix,iy).X>=0) and (Edit.MouseCoord(ix,iy).X<=Edit.ColCount) and (Edit.MouseCoord(ix,iy).Y>=0) and (Edit.MouseCoord(ix,iy).Y<=Edit.RowCount) then
begin
replace_Char:=Edit.Cells[Edit.MouseCoord(ix,iy).X,Edit.MouseCoord(ix,iy).Y];
BacktrackFill(Edit.MouseCoord(ix,iy).X,Edit.MouseCoord(ix,iy).Y,SelectedChar,replace_Char[1]);
end;
end;
-----------------------------------------------------------
CLICK HERE TO BE EATEN BY A VAMPIRE
|
|
Zitat
|