H
hq_pan
Unregistered / Unconfirmed
GUEST, unregistred user!
在介绍如何使用Delphi自带的Zlib.pas的时候,大家给出的例子几乎都是一样的,
解压的时候无一例外的源流肯定是TFileStream!!!!!!!!!!!!!!!
如:
procedure UnCompressData(const CompressedStream: TFileStream;
var SDestStream: TMemoryStream);
var
SourceStream: TDecompressionStream;
DestStream: TMemoryStream;
Buffer: PChar;
Count: Integer;
begin
//从被压缩的流中读出原始的尺寸
CompressedStream.ReadBuffer(Count, SizeOf(Count));
//根据尺寸大小为将要读入的原始流分配内存块
GetMem(Buffer, Count);
DestStream := TMemoryStream.Create;
SourceStream := TDecompressionStream.Create(CompressedStream);
Try
//将被压缩的流解压缩,然后存入 Buffer内存块中
SourceStream.ReadBuffer(Buffer^, Count);
//将原始流保存至 DestStream流中
DestStream.WriteBuffer(Buffer^, Count);
DestStream.Position := 0;//复位流指针
//从 DestStream流中载入流
sDestStream.LoadFromStream(DestStream);
finally
FreeMem(Buffer);
DestStream.Free;
end;
end;
那位高手能给出一个都是使用TMemoryStream的解压过程出来??
如:procedure UnCompressData(const SourceMS: TMemoryStream;
var DestMS: TMemoryStream);
此外,能否给出一步解压一个文件的例子??
如:procedure UnCompressFile(const FileName: string);
很急啊!!!!!!!!!!!
解压的时候无一例外的源流肯定是TFileStream!!!!!!!!!!!!!!!
如:
procedure UnCompressData(const CompressedStream: TFileStream;
var SDestStream: TMemoryStream);
var
SourceStream: TDecompressionStream;
DestStream: TMemoryStream;
Buffer: PChar;
Count: Integer;
begin
//从被压缩的流中读出原始的尺寸
CompressedStream.ReadBuffer(Count, SizeOf(Count));
//根据尺寸大小为将要读入的原始流分配内存块
GetMem(Buffer, Count);
DestStream := TMemoryStream.Create;
SourceStream := TDecompressionStream.Create(CompressedStream);
Try
//将被压缩的流解压缩,然后存入 Buffer内存块中
SourceStream.ReadBuffer(Buffer^, Count);
//将原始流保存至 DestStream流中
DestStream.WriteBuffer(Buffer^, Count);
DestStream.Position := 0;//复位流指针
//从 DestStream流中载入流
sDestStream.LoadFromStream(DestStream);
finally
FreeMem(Buffer);
DestStream.Free;
end;
end;
那位高手能给出一个都是使用TMemoryStream的解压过程出来??
如:procedure UnCompressData(const SourceMS: TMemoryStream;
var DestMS: TMemoryStream);
此外,能否给出一步解压一个文件的例子??
如:procedure UnCompressFile(const FileName: string);
很急啊!!!!!!!!!!!