车
车超
Unregistered / Unconfirmed
GUEST, unregistred user!
如:
type TTUDPHead=record
MsgType:String[2];
end;
type TBody=packed record
ss:TMemoryStream;
end;
type
TSdate=record
Head:TTUDPHead;
Body:TBody;
end;
发送
sd.Head.MsgType:='1';
sd.Body.ss := TMemoryStream.Create;
jpg := TJpegImage.Create;
jpg.Assign(Image.Picture.Bitmap);
jpg.CompressionQuality := 50;
jpg.JPEGNeeded;
jpg.Compress;
jpg.SaveToStream(sd.Body.ss);
jpg.Free;
IdUDPServer1.SendBuffer('192.168.1.88',8581,sd,sizeof(sd));
接收
BufferLen := AData.Size;
rr.Body.ss := TMemoryStream.Create;
rr.Body.ss.Size := BufferLen;
try
AData.ReadBuffer(rr,Bufferlen);
except
end;
jpg := TJpegImage.Create;
jpg.LoadFromStream(rr.Body.ss);
Image.Picture.Bitmap.Assign(jpg);
jpg.Free;
memStream.Free;
结果是错误的,请问应该怎么改才是正确的?
type TTUDPHead=record
MsgType:String[2];
end;
type TBody=packed record
ss:TMemoryStream;
end;
type
TSdate=record
Head:TTUDPHead;
Body:TBody;
end;
发送
sd.Head.MsgType:='1';
sd.Body.ss := TMemoryStream.Create;
jpg := TJpegImage.Create;
jpg.Assign(Image.Picture.Bitmap);
jpg.CompressionQuality := 50;
jpg.JPEGNeeded;
jpg.Compress;
jpg.SaveToStream(sd.Body.ss);
jpg.Free;
IdUDPServer1.SendBuffer('192.168.1.88',8581,sd,sizeof(sd));
接收
BufferLen := AData.Size;
rr.Body.ss := TMemoryStream.Create;
rr.Body.ss.Size := BufferLen;
try
AData.ReadBuffer(rr,Bufferlen);
except
end;
jpg := TJpegImage.Create;
jpg.LoadFromStream(rr.Body.ss);
Image.Picture.Bitmap.Assign(jpg);
jpg.Free;
memStream.Free;
结果是错误的,请问应该怎么改才是正确的?