Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 16:25 
Ich versuche, die Zeichenfunktion von mspaint.exe nachzuprogrammieren. Man öffnet Paint, der 'Stift' ist aktiviert und man malt beliebige Dinge. Das wollte ich selber machen.
Ich benutze ein Image und im OnMouseDown und OnMouseMove verändere ich die Farbe:
ausblenden Delphi-Quelltext
1:
image1.canvas.pixels[X,Y] := AColor;					

Geht auch, nur ist die Perfomance schlecht. In Paint sind durchgezogene Linien und bei mir sind ab und zu mal Pixel weiß geblieben, d.h. das Programm kommt mit den Zeichnen nicht nach. Woran liegt so etwas? Wie kann man das lösen?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 28.07.06 16:54 
Mit Canvas.MoveTo und Canvas.LineTo vielleicht?

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 16:55 
user profile iconBorn-to-Frag hat folgendes geschrieben:
Mit Canvas.MoveTo und Canvas.LineTo vielleicht?

Und was machst du wenn der Benutzer nur einmal klickt?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 28.07.06 17:01 
Dann kommt ein Punkt.. im OnMouseUp einfach nochmal LineTo und bei OnMouseDown MoveTo ;)

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 17:03 
user profile iconBorn-to-Frag hat folgendes geschrieben:
Dann kommt ein Punkt.. im OnMouseUp einfach nochmal LineTo und bei OnMouseDown MoveTo ;)

Hm, ich weiß nicht so recht wie du das meinst :?!?:
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 17:10 
Hab ne Idee und probiere sie aus.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 17:20 
Es funzt :dance:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
//OnMouseMove 
 LineTo(X,Y);
 MoveTo(X,Y);
//OnMouseDowm
  MoveTo(x,y);
  Pixels[X,Y] := AColor;
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 28.07.06 17:43 
pixels brauchst du dann aber nicht mehr ;)

EDIT: Bei on MouseMove brauchst du auch kein MoveTo mehr, das macht LineTo schon...

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 28.07.06 22:02 
user profile iconBorn-to-Frag hat folgendes geschrieben:
pixels brauchst du dann aber nicht mehr ;)

Doch, sonst kann man keinen einzlnen Punkt setzen.
user profile iconBorn-to-Frag hat folgendes geschrieben:
EDIT: Bei on MouseMove brauchst du auch kein MoveTo mehr, das macht LineTo schon...

Ok, hast recht. ;)
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Fr 28.07.06 22:09 
user profile iconMarco D. hat folgendes geschrieben:
user profile iconBorn-to-Frag hat folgendes geschrieben:
pixels brauchst du dann aber nicht mehr ;)

Doch, sonst kann man keinen einzlnen Punkt setzen.


Da haste Recht, aber ein simples LineTo(X, Y) im OnMouseUp-Event tuts auch ;)

Das ist warscheinlich performantisch besser als immer wieder Pixels[X, Y] noch mal zusätzlich aufzurufen :D

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.