S
sdmb
Unregistered / Unconfirmed
GUEST, unregistred user!
压缩方法
是
users zlib;
procedure CompressIt(var CompressedStream: TMemoryStream;
const CompressionLevel: TCompressionLevel);
var SourceStream: TCompressionStream;
DestStream: TMemoryStream;
Count: int64;
//注意,此处修改了,原来是int
begin
Count := CompressedStream.Size;
//获得流的原始尺寸
DestStream := TMemoryStream.Create;
SourceStream := TCompressionStream.Create(CompressionLevel, DestStream);
try
CompressedStream.SaveToStream(SourceStream);
//SourceStream中保存着原始的流
SourceStream.Free;
//将原始流进行压缩,DestStream中保存着压缩后的流
CompressedStream.Clear;
CompressedStream.WriteBuffer(Count, SizeOf(Count));
//写入原始图像的尺寸
CompressedStream.CopyFrom(DestStream, 0);
//写入经过压缩的流
finally
DestStream.Free;
end;
end;
如何用java进行解压缩?
是
users zlib;
procedure CompressIt(var CompressedStream: TMemoryStream;
const CompressionLevel: TCompressionLevel);
var SourceStream: TCompressionStream;
DestStream: TMemoryStream;
Count: int64;
//注意,此处修改了,原来是int
begin
Count := CompressedStream.Size;
//获得流的原始尺寸
DestStream := TMemoryStream.Create;
SourceStream := TCompressionStream.Create(CompressionLevel, DestStream);
try
CompressedStream.SaveToStream(SourceStream);
//SourceStream中保存着原始的流
SourceStream.Free;
//将原始流进行压缩,DestStream中保存着压缩后的流
CompressedStream.Clear;
CompressedStream.WriteBuffer(Count, SizeOf(Count));
//写入原始图像的尺寸
CompressedStream.CopyFrom(DestStream, 0);
//写入经过压缩的流
finally
DestStream.Free;
end;
end;
如何用java进行解压缩?