我需要做的是压缩来自外部服务的 64KB 文件 block ,然后将该压缩数据 block 实时传输到浏览器。 Xceed Real-Time 非常出色,您可以设置文件头,然后将多个 64KB block 拼凑成客户端上的整个压缩文件。这非常有效,您可以通过将其放入循环中轻松处理多个文件。
我的问题是:是否有一个免费的替代压缩实用程序可以与 Xceed 的复杂程度相匹配?我需要一些可以压缩文件部分并将其传输到浏览器的东西。我见过的几乎所有免费替代方案都需要在进行压缩之前访问整个文件。 Xceed 很棒,但是很贵。只是想知道是否有一个免费的替代方案可以实现这一点。谢谢!
最佳答案
您正在寻找的是流压缩方法。好消息是您有很多选择。另请注意,您必须考虑内存,因为某些解决方案(基于字典)可能需要大量内存,因此需要测试和调整。
为了让我的答案简短,我建议尝试一下LZ4。
LZ4 - http://code.google.com/p/lz4/
LZ4 is a very fast lossless compression algorithm, providing compression speed at 300 MB/s per core, scalable with multi-cores CPU. It also features an extremely fast decoder, with speed in GB/s per core, typically reaching RAM speed limits on multi-core systems.
基准:
Name Ratio C.speed D.speed
MB/s MB/s
LZ4 (r97) 2.084 410 1810
LZO 2.06 2.106 409 600
QuickLZ 1.5.1b6 2.237 373 420
Snappy 1.1.0 2.091 323 1070
LZF 2.077 270 570
zlib 1.2.8 -1 2.730 65 280
LZ4 HC (r97) 2.720 25 2040
zlib 1.2.8 -6 3.099 21 300
有很多可用的实现,请检查:http://code.google.com/p/lz4/
LZO - http://lzo-net.sourceforge.net/
LZO.Net brings the power of Markus "FXJ" Oberhumer's great LZO compression library (V1.08) to .Net. It wraps the access to the native DLL with a small C# class maintaining the raw speed of the ANSI-C library.
Snappy - https://code.google.com/p/snappy/
Snappy is a compression/decompression library. It does not aim for maximum compression, or compatibility with any other compression library; instead, it aims for very high speeds and reasonable compression.
有两个 C# native 实现可用:
- SnappySharp - https://github.com/Kintaro/SnappySharp
- Snappy.Sharp - https://github.com/jeffesp/Snappy.Sharp
QuickLZ - http://www.quicklz.com/
QuickLZ is the world's fastest compression library, reaching 308 Mbyte/s per core. It can be used under a commercial license if such has been acquired or under GPL 1, 2 or 3 where anything released into public must be open source.
native 实现 - QuickLZ C#
So far, only a subset of the library has been ported,
namely the setting:
QLZ_COMPRESSION_LEVEL = 1 or 3
QLZ_STREAMING_BUFFER = 0
QLZ_MEMORY_SAFE = 0
关于.net - 是否有像 Xceed Real-Time Zip 这样实时压缩的免费压缩实用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18028199/