Z
zhbj
Unregistered / Unconfirmed
GUEST, unregistred user!
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;
// 参数是传递的流和压缩方式
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;