我是个新手,问一个问题!谁告诉我给200分!(100分)

  • 主题发起人 主题发起人 tongyong1
  • 开始时间 开始时间
T

tongyong1

Unregistered / Unconfirmed
GUEST, unregistred user!
image1.picture.bitmap:=fscreen

fscreen为抓取的屏幕。

我想用nmudp1组件把fscreen发出去,请问如何写代码!?
 
谁可以告诉我啊?
 
首先把fscreen保存到一个内存流中,然后使用SendStream或SendBuffer发送
 
不知道怎么写代码?能告诉我吗?
mystream:tmemorystream;
mystream.write()这括号里怎么写?
告诉我好吗
 
谁告诉我啊?
 
用TBitmap.SaveToStream(myStream)
然后用nmudp1.SendStream发出去
 
接收方应该怎么处理了?
谢谢
 
接收方可以使用ReceiveBuffer方法应该就可以了
 
tongyong1兄
我遇到了一个与你一样的问题 不知道你解决没有 用SENDSTREAM 我在发送时总是报错 搞不清楚原因
 
var
FullScreen:TBitmap;
FullScreenCanvas:TCanvas;
DC:HDC;
TmpStr:string;
iSize,iSendSize,iAllSize,iPosition:Integer;
BmpStream,TmpStream:TMemoryStream;
JPEGImage:TJPEGImage;
begin
BmpStream:=TMemoryStream.Create;
TmpStream:=TMemoryStream.Create;
try
BmpStream.Clear;
CUDP.ReadStream(BmpStream);
SetLength(TmpStr,NumberBytes);
BmpStream.Read(TmpStr[1],NumberBytes);
if TmpStr='Clist' then
begin
Edit1.Text:=FromIP;
CUDP.RemoteHost:=FromIP;
CUDP.RemotePort:=Port;
WindowState:=wsMinimized;
FullScreen:=TBitmap.create;
JPEGImage:=TJPEGImage.Create;
try
FullScreenCanvas:=TCanvas.Create;
DC:=GetDC(0);
try
FullScreen.Width:=Screen.Width;
FullScreen.Height:=Screen.Height;
FullScreenCanvas.Handle:=DC;
FullScreen.Canvas.CopyRect(Rect(0,0,Screen.Width,Screen.Height),FullScreenCanvas,Rect(0,0,Screen.Width,Screen.Height));
finally
ReleaseDC(0,DC);
FullScreenCanvas.free;
end;
BmpStream.Clear;
JPEGImage.Assign(FullScreen);
JPEGImage.CompressionQuality:=20;
JPEGImage.Compress;
JPEGImage.SaveToStream(BmpStream);
iAllSize:=BmpStream.Size;
iSize:=0;
TmpStr:='SENDSTART'+IntToStr(iAllSize);
TmpStream.Clear;
TmpStream.Write(tmpstr[1],Length(TmpStr));
CUDP.SendStream(TmpStream);
BmpStream.Seek(0,0);
iPosition:=0;
While iSize<iAllSize do
begin
iSendSize:=iAllSize-iPosition;
if iSendSize>2048 then
iSendSize:=2048;

TmpStream.Clear;
TmpStream.CopyFrom(BmpStream,iSendSize);
TmpStream.Seek(0,0);
CUDP.SendStream(TmpStream);
Inc(iSize,iSendSize);
iPosition:=iSize;
BmpStream.Position:=iSize;
if iSendSize=0 then
Break;
StatusBar1.SimpleText:=IntToStr(iSize)+' of '+IntToStr(iAllSize)+' '+IntToStr(iSendSize);
Sleep(1);
end;
Sleep(1);
TmpStr:='OK';
TmpStream.Clear;
TmpStream.Write(tmpstr[1],Length(TmpStr));
TmpStream.Seek(0,0);
CUDP.SendStream(TmpStream);
finally
FullScreen.Free;
JPEGImage.Free;
WindowState:=wsNormal;
end;
end;
finally
BmpStream.Free;
TmpStream.Free;


end;
end;
 
后退
顶部