一
Procedure OnProgress (Sender: TObject); dynamic;
Property CompressionRate: Single read GetCompressionRate;通過這個屬性
它的幾個重要的方法定義如下
Constructor TCompressionStream
其中
①
②
③
④
Dest
Function TCompressionStream
其中
Count: 需要壓縮的數據的字節數
函數返回寫入流的字節數
壓縮類TCompressionStream的數據只能是寫入的
構造函數
其中
Function Read(var Buffer; Count: Longint): Longint;
數據讀出函數
Count: 緩沖區的大小
函數返回讀出的字節數
數據在讀出的過程中
二
通過類TCompressionStream和TdecompressionStream的配合使用
Procedure TClientForm
Var
SourceDC
Bhandle:HBITMAP;
BitMap:TBitMap;
BmpStream
SourceStream:TCompressionStream;
Count:Integer;
Begin
SourceDC:=CreateDC(
{得到屏幕的 DC}
DestDC:=CreateCompatibleDC(SourceDC);
{建立臨時 DC}
Bhandle:=CreateCompatibleBitmap(SourceDC
{建立位圖}
SelectObject(DestDC
{選擇位圖DC}
BitBlt(DestDC
{拷貝整個屏幕}
BitMap:=TBitMap
BitMap
{保存屏幕位圖到 BitMap中}
BmpStream:=TMemoryStream
BitMap
{建立位圖數據的內存流}
count:=BmpStream
{保存位圖的大小}
DestStream:=TMemoryStream
{目標流
SourceStream:=TCompressionStream
{構建壓縮流
try
BmpStream
{壓縮位圖流}
SourceStream
{完成壓縮
BmpStream
{清空原來位圖流}
BmpStream
{將原來位圖的大小保存到新的位圖流中
BmpStream
{將壓縮數據附加到新的位圖流後面}
BmpStream
NMStrm
{發送位圖流}
finally
DestStream
BmpStream
BitMap
DeleteDC(SourceDC);
ReleaseDC(Bhandle
end;
{釋放有關資源}
End;
該過程得到整個屏幕的圖象拷貝
procedure TServerForm
const sFrom: String; strm: TStream);
Var
StreamStr
SourceStream:TDecompressionStream;
count:Integer;
buffer:pointer;
begin
ScreenImage
If Strm Is TMemoryStream Then
StreamStr := Strm AS TMemoryStream
Else
Exit;
StreamStr
StreamStr
{得到位圖的大小}
GetMem(Buffer
{申請數據空間}
DestStream := TMemoryStream
SourceStream := TDecompressionStream
{構建解壓流
StatusBar
Try
SourceStream
{讀出解壓數據}
DestStream
{保存到位圖流中}
DestStream
ScreenImage
{顯示到屏幕上}
Finally
FreeMem(Buffer);
DestStream
SourceStream
End;
end;
該過程首先從得到的數據流中取得位圖大小
From:http://tw.wingwit.com/Article/program/Delphi/201311/24717.html