Hi, ich hab ein Problem.
Ich hab ne Methode geschrieben mit der man Flächen ausfüllen kann. Ich dachte mir: Hey, das mach ich rekursiv, wirdn Klacks! Wars auch und die ersten Rechtecke waren schnell gefüllt, aber als ich versucht hab größere Flächen zu füllen, stürzte das Programm sofort ab, es gab nichtmal eine Fehlermeldung.
Ich hab herausgefunden, dass Rechtecke bis zu einem Flächeninhalt von 47499 Pixeln gefüllt werden, alles darüber... Gibt es da Beschränkungen, was sich selbst aufrufende Funktionen angeht? Hier mein code:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
| procedure TQxGCore.FloodFill(p: TQxPoint); begin if (p.x < 0) or (p.x >= fsystem.screen.w) or (p.y < 0) or (p.y >= fsystem.screen.h) then exit; if fsystem.status <> stRunning then exit; HlpFloodFill(p.x, p.y, getPixel(p.x, p.y)); end;
procedure TQxGCore.HlpFloodFill(x, y, c: cardinal); begin setPixel(x, y, getR(brush.color), getG(brush.color), getB(brush.color)); if x > 0 then if getPixel(x - 1, y) = c then HlpFloodFill(x - 1, y, c); if x < fsystem.width - 1 then if getPixel(x + 1, y) = c then HlpFloodFill(x + 1, y, c); if y > 0 then if getPixel(x, y - 1) = c then HlpFloodFill(x, y - 1, c); if y < fsystem.height - 1 then if getPixel(x, y + 1) = c then HlpFloodFill(x, y + 1, c); end; |
Hilfe! (Bitte)