W
wanggongqin
Unregistered / Unconfirmed
GUEST, unregistred user!
这是客户端接收流的代码:
procedure TScreenfrm.ClientSocketRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Buf: array[0..100000] of Byte;
Len: Integer;
Bmp: TBitmap;
TmpStr: string;
begin
if FStreamSize = 0 then
begin
TmpStr := Trim(Socket.ReceiveText);
if TmpStr = '' then Exit;
try
FStreamSize := StrToInt(TmpStr); //接收服务端发过来的准备发送的流的大小
Socket.SendText(CMD_ReadySend); //给服务端发送已准备好的消息,以便服务端开发发送流
except end;
end else
begin
Len := Socket.ReceiveLength;
Socket.ReceiveBuf(Buf, Len);
FSecondStream.Write(Buf, Len);
if FSecondStream.Size >= FStreamSize then
begin
try
FSecondStream.Position := 0;
Bmp := TBitmap.Create;
Bmp.LoadFromStream(FSecondStream);
ImgScreen.Picture.Bitmap.Assign(Bmp);
Bmp.Free;
finally
Socket.SendText(CMD_BeginCapScr); //连续抓屏
FSecondStream.Clear;
FStreamSize := 0;
end;
end;
end;
end;
当 FSecondStream.Size >= FStreamSize 时,并且服务端还没有发过来流大小的时候,
还会触发 ClientSocketRead 事件?怎么回事。
另外!求一个快速压缩流的算法。必须快才能满足我的要求,请各位帮帮忙。
全部源代码可从下面的网址下载:
http://bbs.2ccc.com/attachments/2006/wgqsoft_2006102085843.rar
其中 LibCompress、SpzLibrary 两个单元是照抄 DynamicSkinForm 组件包中的代码
procedure TScreenfrm.ClientSocketRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Buf: array[0..100000] of Byte;
Len: Integer;
Bmp: TBitmap;
TmpStr: string;
begin
if FStreamSize = 0 then
begin
TmpStr := Trim(Socket.ReceiveText);
if TmpStr = '' then Exit;
try
FStreamSize := StrToInt(TmpStr); //接收服务端发过来的准备发送的流的大小
Socket.SendText(CMD_ReadySend); //给服务端发送已准备好的消息,以便服务端开发发送流
except end;
end else
begin
Len := Socket.ReceiveLength;
Socket.ReceiveBuf(Buf, Len);
FSecondStream.Write(Buf, Len);
if FSecondStream.Size >= FStreamSize then
begin
try
FSecondStream.Position := 0;
Bmp := TBitmap.Create;
Bmp.LoadFromStream(FSecondStream);
ImgScreen.Picture.Bitmap.Assign(Bmp);
Bmp.Free;
finally
Socket.SendText(CMD_BeginCapScr); //连续抓屏
FSecondStream.Clear;
FStreamSize := 0;
end;
end;
end;
end;
当 FSecondStream.Size >= FStreamSize 时,并且服务端还没有发过来流大小的时候,
还会触发 ClientSocketRead 事件?怎么回事。
另外!求一个快速压缩流的算法。必须快才能满足我的要求,请各位帮帮忙。
全部源代码可从下面的网址下载:
http://bbs.2ccc.com/attachments/2006/wgqsoft_2006102085843.rar
其中 LibCompress、SpzLibrary 两个单元是照抄 DynamicSkinForm 组件包中的代码