有没有支持Stream的zip解压控件(100分)

  • 主题发起人 主题发起人 cmzhotpot
  • 开始时间 开始时间
C

cmzhotpot

Unregistered / Unconfirmed
GUEST, unregistred user!
有没有支持输入输出都是Stream的zip压缩/解压控件,最好带源码。
我用了VCLZip, TruboPower的 Abbrevia,好像输入都不支持Stream,
如有人知道请告知用法,本人不胜感激。
 
你可以仿照下面的内容作出来,从网上搜的程序改编而来

uses
zlib;

procedure CompressStream(var CompressedStream: TMemoryStream;
const CompressionLevel: TCompressionLevel);
//压缩方式:clnone,clfastest,cldefault,clmax
procedure giveScreen(const CompressedStream: TMemoryStream; var Bmp: TBitmap);

procedure CompressStream(var CompressedStream: TMemoryStream;
const CompressionLevel: TCompressionLevel);
var
SourceStream: TCompressionStream;
DestStream: TMemoryStream;
Count: Integer;
infono:integer;
Begin
//获得图像流的原始尺寸
infono:=1;
Count := CompressedStream.Size;
DestStream := TMemoryStream.Create;
SourceStream:=TCompressionStream.Create(CompressionLevel, DestStream);
Try
//SourceStream中保存着原始的图像流
CompressedStream.SaveToStream(SourceStream);
//将原始图像流进行压缩, DestStream中保存着压缩后的图像流
SourceStream.Free;
CompressedStream.Clear;
//写入原始图像的尺寸
CompressedStream.WriteBuffer(Infono,SizeOf(Infono));
CompressedStream.WriteBuffer(Count, SizeOf(Count));
//写入经过压缩的图像流
CompressedStream.CopyFrom(DestStream,0);
finally
DestStream.Free;
end;
end;

procedure giveScreen(const CompressedStream: TMemoryStream; var Bmp: TBitmap);
var
SourceStream: TDecompressionStream;
DestStream: TMemoryStream;
Buffer: PChar;
Count: Integer;
Begin
//从被压缩的图像流中读出原始图像的尺寸
//CompressedStream.position:=0;
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流中载入原始图像流
Bmp.LoadFromStream(DestStream);
finally
FreeMem(Buffer);
DestStream.Free;
SourceStream.Free;
end;
end;
 
就是使用delphi自带的zlib了,支持流压缩。
看看我以前问的问题:
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1141472
 
上面redfox写的是zLib的压缩算法,Zip的我也没找到。zLib的Delphi自己带,压缩率我觉的
还可以,试试看!
 
TruboPower的 Abbrevia
deflatestream(soucestream,compressstream);//压缩
inflatestream(compressstream,soucestream);//解压缩
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部