张
张校风
Unregistered / Unconfirmed
GUEST, unregistred user!
发送端代码:
procedure TForm1.Button4Click(Sender: TObject);
begin
tempbmp:= Tbitmap.Create;
tempbmp := getformimage;
ImageStream:= Tmemorystream.Create;
try
tempbmp.SaveToStream(imagestream);
NMUDP1.SendStream(imagestream);
finally
imagestream.Free;
tempbmp.free;
end;
end;
接收端代码:
procedure TForm4.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
MyStream: TMemoryStream;
begin
MyStream := TMemoryStream.Create;
try
NMUDP1.ReadStream(MyStream);
image1.Picture.Bitmap.LoadFromStream(MyStream);
finally
MyStream.Free;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
tempbmp:= Tbitmap.Create;
tempbmp := getformimage;
ImageStream:= Tmemorystream.Create;
try
tempbmp.SaveToStream(imagestream);
NMUDP1.SendStream(imagestream);
finally
imagestream.Free;
tempbmp.free;
end;
end;
接收端代码:
procedure TForm4.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
MyStream: TMemoryStream;
begin
MyStream := TMemoryStream.Create;
try
NMUDP1.ReadStream(MyStream);
image1.Picture.Bitmap.LoadFromStream(MyStream);
finally
MyStream.Free;
end;
end;