Autor Beitrag
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 26.05.08 17:57 
user profile iconWolle92 hat folgendes geschrieben:
das flimmert aber wie sonstwas...

und trotzdem ich eigentlich beim onmouseup die linie dann direkt in die Bitmap zeichne wirs die nicht gespeichert:
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:
46:
47:
48:
49:
50:
procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  mouseDown := true;
  startX := X;
  startY := Y;
  oldX := X;
  oldY := Y;
  Bitmap1.Canvas.MoveTo(X, Y);  //das würde ich später machen..
end;

procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  StatusBar1.Panels[1].Text := IntToStr(X) + ', ' + IntToStr(Y);
  PaintBox1.Repaint;  //wozu repaint, wenn du nichst verändert hast?
  if not mouseDown then Exit;
  PaintBox1.Repaint;  //hier muss es hin, dann flimmerts nicht. Alternativ gibts Doublebuffered
  case drawMode of
    dmFree: Bitmap1.Canvas.LineTo(X, Y);
    dmLine:
    begin
      PaintBox1.Canvas.MoveTo(startX, startY);
      PaintBox1.Canvas.LineTo(X, Y);
      oldX := X;
      oldY := Y;
    end;
    dmBorderRect:
    begin
      PaintBox1.Canvas.Rectangle(startX, startY, X, Y);
      oldX := X;
      oldY := Y;
    end;
  end;
end;

procedure TForm1.PaintBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  mouseDown := false;
  case drawMode of
    dmLine:
    begin
      Bitmap1.Canvas.MoveTo(oldX, oldY);
      Bitmap1.Canvas.LineTo(startX, startY);
    end;
    dmBorderRect: Bitmap1.Canvas.Rectangle(startX, startY, oldX, oldY);
  end;
  PaintBox1.Repaint;  //sonst siehst du nichts
end;


Hast du ins OnPaint reingeschrieben "PaintBox1.Canvas.Stretchdraw(PaintBox1.ClientRect, Bitmap1)"?

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
G-S
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.05.08 18:10 
Wie wärs, wenn du 2 TIMages verwendest?

Auf der unteren ist das eigentlich Bild, auf der oberen die Linie und diese wird erst bei OnMouseClick auf die untere übertragen, somit brauchst du das obere Image-Objekt nur zu "leeren".
Wolle92 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1296

Windows Vista Home Premium
Delphi 7 PE, Delphi 7 Portable, bald C++ & DirectX
BeitragVerfasst: Mo 26.05.08 18:25 
daran hatte ich auch est gedacht, jetzt bin ich aber auf die PaintBox umgestiegen...

Ja, ich habs ins OnPaint reingepackt

_________________
1405006117752879898543142606244511569936384000000000.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Mo 26.05.08 19:19 
user profile iconG-S hat folgendes geschrieben:
Wie wärs, wenn du 2 TIMages verwendest?

Auf der unteren ist das eigentlich Bild, auf der oberen die Linie und diese wird erst bei OnMouseClick auf die untere übertragen, somit brauchst du das obere Image-Objekt nur zu "leeren".


Hi,

Das ist genau der falsche Ansatz. Man braucht stets maximal eine Bildausgabe.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)