Thema: Delphi Paintbox flackert

Einzelnen Beitrag anzeigen

delphi-n

Registriert seit: 6. Sep 2009
88 Beiträge
 
#1

Paintbox flackert

  Alt 10. Okt 2009, 12:48
Hi!

Ich hab eine procedure "zeichnen". Sie wird alle 200 millisec aufgerufen.
Diese funktioniert auch, und ist folgendermaßen aufgebaut:


Delphi-Quellcode:
procedure TForm2.Zeichnen;
var x,y,z: integer;
begin
PaintBox1.Refresh; //löschen der Paintbox
    for z:=0 to 9 do //zeichen kleinerer Objekte (der hintergrund ist auf einem anderen Image)
    begin
        for x:=0 to 14 do
        begin
            for y:=0 to 14 do
            begin
            if Q[x,y,z]=1 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+131+Aposz*15-Aposy*15+Ba, Image11.Picture.Graphic);
            if Q[x,y,z]=2 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15+Bb, Image2.Picture.Graphic);
            if Q[x,y,z]=3 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image3.Picture.Graphic);
            if Q[x,y,z]=4 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image4.Picture.Graphic);
            if Q[x,y,z]=5 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image5.Picture.Graphic);
            if Q[x,y,z]=6 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image7.Picture.Graphic);
            if Q[x,y,z]=7 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image8.Picture.Graphic);
            if Q[x,y,z]=8 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image9.Picture.Graphic);
            if Q[x,y,z]=9 then
            PaintBox1.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image10.Picture.Graphic);


            end;
        end;
    end;

end;
Leider flackert das alles (wegen der Zeit zwischen löschen und neu zeichnen).
Nun hatte ich gehört, dass es besser wär alles erstmal aufzubauen, und das fertige bild in ein image oder eine Paintbox zu kopieren.
Da die PaintBox aber kein Bildspeicher hat, habe ich ein Image genommen. Leider kommen fehler.



Delphi-Quellcode:
procedure TForm2.Zeichnen;
var x,y,z: integer;
begin
PaintBox1.Refresh; //löschen des paintbox-inhalts
Image14.Picture.Destroy; //löschen des Image-inhaltes
Image14.Canvas.Draw(0,0, Image1.Picture.Graphic); //zeichnen des hintergrundes auf das image //hier kommt der Fehler s.u.
    for z:=0 to 9 do //zeichen kleinerer objekte
    begin
        for x:=0 to 14 do
        begin
            for y:=0 to 14 do
            begin
            if Q[x,y,z]=1 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+131+Aposz*15-Aposy*15+Ba, Image11.Picture.Graphic);
            if Q[x,y,z]=2 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15+Bb, Image2.Picture.Graphic);
            if Q[x,y,z]=3 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image3.Picture.Graphic);
            if Q[x,y,z]=4 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image4.Picture.Graphic);
            if Q[x,y,z]=5 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image5.Picture.Graphic);
            if Q[x,y,z]=6 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image7.Picture.Graphic);
            if Q[x,y,z]=7 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image8.Picture.Graphic);
            if Q[x,y,z]=8 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image9.Picture.Graphic);
            if Q[x,y,z]=9 then
            Image14.Canvas.Draw(PaintBox1.Left+224+Aposx*30-Aposz*15, PaintBox1.Top+152+Aposz*15-Aposy*15, Image10.Picture.Graphic);


            end;
        end;
    end;
 Image13.Canvas.Draw(0,0,Image14.Picture.Graphic); //kopieren des gesamtbildes auf das für den nutzer sichbare image
end;

diese fehler kommen:

Zitat:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt Project1.exe ist eine Exception der Klasse EAccessViolation aufgetreten. Meldung: 'Zugriffsverletzung bei Adresse 42F82B68. Lesen von Adresse 42F82B68'. Prozess wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
---------------------------
OK Hilfe
---------------------------




---------------------------
Project1
---------------------------
Zugriffsverletzung bei Adresse 42F82B68. Lesen von Adresse 42F82B68.
---------------------------
OK
---------------------------



---------------------------
Anwendungsfehler
---------------------------
Exception EExternalException in Modul Project1.exe bei 00A47501.

Externe Exception C000001D.


---------------------------
OK
---------------------------

Ich hoffe ihr könnt mir weiterhelfen.

Vielen Dank schon mal,
Delphi-n
  Mit Zitat antworten Zitat