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;