delphi - Indy 的 TIdCompressorZLib.compressStream 方法的参数记录在哪里?

标签 delphi c++builder indy zlib

TIdComproessorZLib 组件用于 Delphi/C++ Builder Indy 库中的压缩和解压缩。 CompressStream 方法具有以下定义:

public: virtual __fastcall CompressStream(TStream AInStream, TStream AOutStream, const TIdCompressionLevel ALevel, const int AWindowBits, const int AMemLevel, const int AStrategy);

帮助文件中这些参数的完整描述是:

CompressStream is a public overridden procedure. that implements the abstract the virtual method declared in the ancestor class.

AInStream is the stream containing the uncompressed contents used in the compression operation.

AOutStream is the stream used to store the compressed contents from the compression operation. AOutStream is cleared prior to outputting the compressed contents from the operation. When AOutStream is omitted, the stream in AInStream is cleared and reused for the output from the compression operation.

Use ALevel to indicate the desired compression level for the operation.

Use AWindowsBits and AMemLevel to control the memory footprint required to perform in-memory compression using the ZLib library.

Use AStrategy to control the RLE-encoding strategy used in the compression operation.

TIdCompressionLevel 的帮助页面上定义了 ALevel 的值,但我找不到任何关于 AWindowBits、AMemLevel 或 AStrategy 应该使用什么值的指示,它们只是整数。

我查看了源代码,但 CompressStream 只是委托(delegate)给 IndyCompressStream,它在帮助文件中列出为:

IndyCompressStream(TStream InStream, TStream OutStream, const int level = Z_DEFAULT_COMPRESSION, const int WinBits = MAX_WBITS, const int MemLevel = MAX_MEM_LEVEL, const int Stratagy = Z_DEFAULT_STRATEGY);

IndyCompressStream 的帮助甚至没有列出 CompressStream 所包含的参数的最少描述。

我找到了(我认为)IndyCompressStream live 中提到的默认常量的文件,source\Indy10\Protocols\IdZLibHeaders.pas,它们是

  Z_DEFAULT_STRATEGY    = 0;
  Z_DEFAULT_COMPRESSION  = -1;
  MAX_WBITS = 15; { 32K LZ77 window }
  MAX_MEM_LEVEL = 9;

但是,根据 TIdCompressionLevel 的文档,为 Z_DEFAULT_COMPRESSION 指定的值甚至不是该参数的合法值

是否有一些文档说明 AWindowBits、AMemLevel 和 AStrategy 对该组件的含义以及对它们使用哪些值是合理的?上面列出的值是实际建议的默认值吗?此外,源文件包括“indy”、“Indy10”和“indyimpl”目录。我们应该使用哪一个来查找当前 Indy 组件的源代码?

谢谢!

最佳答案

您需要查看 zlib.h 中的 zlib 文档。特别是parameters to deflateInit2() .

在几乎所有情况下,您唯一应该搞乱的是压缩级别和窗口位。对于窗口位,通常将窗口大小保留为 32K (15),但对于 gzip 格式添加 16 (31),或者取负值 (-15) 以获得没有 header 或标尾的原始 deflate 格式。对于某些特殊类型的数据,您可能会通过不同的压缩策略获得改进,例如图像或其他数值数据数组。

关于delphi - Indy 的 TIdCompressorZLib.compressStream 方法的参数记录在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19186099/

相关文章:

delphi - 用于交互式空间数据可视化的3D库建议?

delphi indy IdDNSResolver 未返回所有请求的 dns 结果

delphi - 如何获取高DPI系统下的真实屏幕分辨率?

delphi - delphi中的对象复制

c++ - 我应该用 Delphi 而不是 C++ Builder 编写组件吗?如何向组件添加事件?

c++ - Borland C++ Builder 5 - 通过 Escape 键取消不起作用

C++ builder 如何配置编译器只输出 exe?

delphi - 无状态 HTTP session 中的进度反馈

Delphi - 可以indy TIdTCPClient同时发送/接收大流

delphi - 使用delphi 2010替换UTF-8文件中的unicode字符