Autor Beitrag
Quivadis
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314

UBUNTU 9.04
D2005 PERS, JAVA, D7 Pers.
BeitragVerfasst: Mi 05.01.05 16:14 
Hallo Freunde,

ich finde den Fehler in dieser Procedure nicht. es wird nicht richtig gefüllt: wenn ich auf meine weisse zeichefläche klicke und vorher als neue farbe blau ausgewählt habe wir die obere rechte ecke/Berich nicht richtig gefüllt, es bleiben weise streifen übrig.

es soll nur das gefüllt werden was der farbe entspricht wo mit der maus vorher geklickt wurde.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
procedure tform1.Fuellen(x,y:integer;farbe:TColor);
//Funktion zum ausmalen von Flächen
var
  help, farbe1: tcolor;
  vorFarbe:tcolor;  // Farbe wo hingeklickt wird, diese Farbe wird übermalt
  x1,y1: integer;  // positive Richtung
  x2,y2: integer;  // negative Richtung
  ix, iy: integer;  // Bildgrösse
begin
  screen.Cursor:=crHourGlass;
  x1:=x;x2:=x;
  y1:=y;y2:=y;
  ix:=image1.Picture.Bitmap.width;
  iy:=image1.Picture.Bitmap.height;
  vorfarbe:= image1.picture.Bitmap.canvas.pixels[x,y];
  while (ix>x1) and (iy>y1) do  // Hauptabbruchbedingung
  begin
    if x1<ix then
    begin
      farbe1:= image1.Canvas.pixels[x1,y1];
      if vorfarbe=farbe1 then
      image1.Canvas.pixels[x1,y1]:=farbe;

      farbe1:= image1.Canvas.pixels[x2,y1];
      if vorfarbe=farbe1 then
      image1.Canvas.pixels[x2,y1]:=farbe;
    end;
    if x2>0 then
    begin
      farbe1:= image1.Canvas.pixels[x2,y2];
      if vorfarbe=farbe1 then
      image1.Canvas.pixels[x2,y2]:=farbe;

      farbe1:= image1.Canvas.pixels[x1,y2];
      if vorfarbe=farbe1 then
      image1.Canvas.pixels[x1,y2]:=farbe;
    end;
    inc(x1);
    if x1=ix then begin x1:=x;inc(y1); end;
    dec(x2);
    if x2=0 then begin x2:=x;dec(y2); end;
  end;

  screen.Cursor:=crDefault;
end;

_________________
Wissen ist macht, nichts wissen macht auch nichts. ODER: Wer nichts weis, kann nichts vergessen.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 05.01.05 18:37 
Moin!

Ich habe - zugegeben - deinen Code nur überflogen, aber IMHO ist deine "Hauptabbruchbedingung" murks. Sofern das kein rekursiver Flächenfüllalgo sein soll, löst man sowas IMHO mit zwei geschachtelten Scheifen, eine für die X, die andere für die Y-Richtung.

cu
Narses
Quattro XLS
Hält's aus hier
Beiträge: 2

XP Home
D3 Pro
BeitragVerfasst: Mi 05.01.05 19:26 
Du hast anstatt 'end.' - 'end;'geschrieben,ich weiß ja nicht wies weiter geht, nur wenn dass das ende ist, ist das defenitiv falsch!!!!!

gruß
dennis