unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdTCPConnection, IdTCPClient, IdBaseComponent, IdComponent,
IdTCPServer, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
server: TIdTCPServer;
client: TIdTCPClient;
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
Image1: TImage;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure serverExecute(AThread: TIdPeerThread);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure updateimg2;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Stream2: TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
server.Active := true;
memo1.Lines[0] := '
';
Stream2 := TMemorystream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
client.Connect();
end;
procedure TForm1.serverExecute(AThread: TIdPeerThread);
begin
Stream2.Clear;
Athread.Connection.ReadStream(Stream2);
AThread.Synchronize(UpdateImg2);
end;
procedure TForm1.updateimg2;
begin
Stream2.Seek(0, soFromBeginning);
Image2.Picture.Bitmap.LoadFromStream(Stream2);
Stream2.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
Var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
Image1.Picture.Bitmap.SaveToStream(Stream);
Client.WriteStream(Stream, true, true);
Stream2.Free;
end;
end.