Einzelnen Beitrag anzeigen

Benutzerbild von vsilverlord
vsilverlord

Registriert seit: 7. Jan 2008
Ort: Baden Württemberg- Hohenlohekreis
174 Beiträge
 
RAD-Studio 2009 Arc
 
#19

Re: Aus bildern Film erzeugen

  Alt 10. Jan 2009, 16:37
also ich hab hier jetzt mal einen code. Wie mach ich tcanvas zu tgraphic?
Delphi-Quellcode:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,CreateAVI, ExtCtrls,math, StdCtrls;

type

  TForm1 = class(TForm)
    Image1: TImage;
    Timer1: TTimer;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Button1Click(Sender: TObject);
  private
    function machpunkt(a,b:integer):tpoint;
 
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  punkt:tpoint;
  allepunkte:array of tpoint;
  allebildchen:array of tcanvas;
  film:tavicreator;

implementation

{$R *.dfm}






function tform1.machpunkt(a: Integer; b: Integer):tpoint;
begin
result.X:=a;
result.Y:=b;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
film:=tavicreator.Create(self);
for i := 0 to length(allebildchen) - 1 do
 begin
   film.AddAVIFrame(allebildchen[i]);
 end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;
punkt:=machpunkt(250,100);
setlength(allepunkte,1);
setlength(allebildchen,1);
allepunkte[0]:=machpunkt(250,100);
image1.Canvas.Ellipse(250,100,10,10);
allebildchen[0]:=image1.Canvas;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i: Integer;
begin
setlength(allepunkte,length(allepunkte)+1);
setlength(allebildchen,length(allebildchen)+1);
image1.Canvas.Rectangle(0,0,image1.Width,image1.Height);
repeat
 begin
   punkt.X:=punkt.X+random(3)-1;
   punkt.Y:=punkt.y+random(3)-1;
 end
until (punkt.X<image1.Height) and (punkt.Y<image1.Height)and (punkt.X>0) and (punkt.Y>0);
allepunkte[length(allepunkte)-1]:=machpunkt(punkt.X,punkt.Y);
image1.Canvas.MoveTo(allepunkte[0].x,allepunkte[0].y);
for i := 1 to length(allepunkte) - 1 do
 begin
  image1.Canvas.LineTo(allepunkte[i-1].X,allepunkte[i-1].y)
 end;
image1.Canvas.Ellipse(punkt.X,punkt.Y,punkt.X+10,punkt.Y+10);
allebildchen[length(allebildchen)-1]:=image1.Canvas
end;

end.
Volker
~beware
Wizards First Rule:
People are stupid; given proper motivation, almost anyone will believe almost anything. Because people are stupid, they will believe a lie because they want to believe it’s true, or because they are afraid it might be true
  Mit Zitat antworten Zitat