我的流为什么接收不到?(100分)

  • 主题发起人 主题发起人 张校风
  • 开始时间 开始时间

张校风

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;
 
tempbmp.SaveToStream(imagestream);

试一试中间加上
imagestream.position:=0;

NMUDP1.SendStream(imagestream);
 
接受答案了.
 
后退
顶部