AdvSim.Compression
1.0.0
dotnet add package AdvSim.Compression --version 1.0.0
NuGet\Install-Package AdvSim.Compression -Version 1.0.0
<PackageReference Include="AdvSim.Compression" Version="1.0.0" />
paket add AdvSim.Compression --version 1.0.0
#r "nuget: AdvSim.Compression, 1.0.0"
// Install AdvSim.Compression as a Cake Addin #addin nuget:?package=AdvSim.Compression&version=1.0.0 // Install AdvSim.Compression as a Cake Tool #tool nuget:?package=AdvSim.Compression&version=1.0.0
AdvSim.Compression
The AdvSim.Compression
NuGet contains a set of compression wrapper functions which are reusable, configured with sane defaults and are easy to use. Further details are available under the different subheadings below.
NuGet Compatibility
The AdvSim.Compression
NuGet supports a wide variety of .Net versions. Due to native API usage, a number of the modules are available only on NETFRAMEWORK
, these have been highlighted in the usage documentation below.
NuGet URL: https://www.nuget.org/packages/AdvSim.Compression
Usage
GZip
GZip
is a standard wrapper around System.IO.Compression
.
// Compression
//====================
// Compress Byte[] to Byte[]
Byte[] bCompressed = GZip.GzipCompress(bUncompressedBuffer);
// Compress File to Byte[]
Byte[] bCompressed = GZip.GzipCompress(sFilePath);
// Compress Byte[] to File
GZip.GzipCompress(bUncompressedBuffer, sFilePath);
// Compress File to File
GZip.GzipCompress(sFilePath, sOutputFilePath);
// Decompression
//====================
// Decompress Byte[] to Byte[]
Byte[] bDecompressed = GZip.GzipDecompress(bCompressedBuffer);
// Decompress File to Byte[]
Byte[] bDecompressed = GZip.GzipDecompress(sFilePath);
// Decompress Byte[] to File
GZip.GzipDecompress(bUncompressedBuffer, sFilePath);
// Decompress File to File
GZip.GzipDecompress(sFilePath, sOutputFilePath);
LZMA
LZMA
is a wrapper built on the 7z
sdk provided here under public domain licencing.
// Compression
//====================
// Compress Byte[] to Byte[]
Byte[] bCompressed = LZMA.LZMACompress(bUncompressedBuffer);
// Compress File to Byte[]
Byte[] bCompressed = LZMA.LZMACompress(sFilePath);
// Compress Byte[] to File
LZMA.LZMACompress(bUncompressedBuffer, sFilePath);
// Compress File to File
LZMA.LZMACompress(sFilePath, sOutputFilePath);
// Decompression
//====================
// Decompress Byte[] to Byte[]
Byte[] bDecompressed = LZMA.LZMACompress(bCompressedBuffer);
// Decompress File to Byte[]
Byte[] bDecompressed = LZMA.LZMACompress(sFilePath);
// Decompress Byte[] to File
LZMA.LZMACompress(bUncompressedBuffer, sFilePath);
// Decompress File to File
LZMA.LZMACompress(sFilePath, sOutputFilePath);
LZNT1
LZNT
is a wrapper around ntdll!RtlCompressBuffer
and ntdll!RtlDecompressBuffer
. More details about LZNT1
are available here. The compression workspace here is using the Standard Engine
.
// Compression
//====================
// Compress Byte[] to Byte[]
Byte[] bCompressed = LZNT.RtlCompressBuffer(bUncompressedBuffer);
// Compress File to Byte[]
Byte[] bCompressed = LZNT.RtlCompressBuffer(sFilePath);
// Compress Byte[] to File
LZNT.RtlCompressBuffer(bUncompressedBuffer, sFilePath);
// Compress File to File
LZNT.RtlCompressBuffer(sFilePath, sOutputFilePath);
// Decompression
//====================
// Decompress Byte[] to Byte[]
Byte[] bDecompressed = LZNT.RtlDecompressBuffer(bCompressedBuffer);
// Decompress File to Byte[]
Byte[] bDecompressed = LZNT.RtlDecompressBuffer(sFilePath);
// Decompress Byte[] to File
LZNT.RtlDecompressBuffer(bUncompressedBuffer, sFilePath);
// Decompress File to File
LZNT.RtlDecompressBuffer(sFilePath, sOutputFilePath);
Direct3D
Direct3D
is using shader compression from D3DCompiler_47!D3DCompressShaders
and D3DCompiler_47!D3DDecompressShaders
. Compression here is really good and I want to give a shout-out to @modexpblog for documenting this here and helping me do some debugging ❤️!
// Compression
//====================
// Compress Byte[] to Byte[]
Byte[] bCompressed = Direct3D.D3DCompressShaders(bUncompressedBuffer);
// Compress File to Byte[]
Byte[] bCompressed = Direct3D.D3DCompressShaders(sFilePath);
// Compress Byte[] to File
Direct3D.D3DCompressShaders(bUncompressedBuffer, sFilePath);
// Compress File to File
Direct3D.D3DCompressShaders(sFilePath, sOutputFilePath);
// Decompression
//====================
// Decompress Byte[] to Byte[]
Byte[] bDecompressed = Direct3D.D3DDecompressShaders(bCompressedBuffer);
// Decompress File to Byte[]
Byte[] bDecompressed = Direct3D.D3DDecompressShaders(sFilePath);
// Decompress Byte[] to File
Direct3D.D3DDecompressShaders(bUncompressedBuffer, sFilePath);
// Decompress File to File
Direct3D.D3DDecompressShaders(sFilePath, sOutputFilePath);
Cabinet
Cabinet
is built mainly around cabinet!Compress
and cabinet!Decompress
. These functions are actually exposed through managed code as well, within Windows.Storage.Compression, however this namespace is tied to the Universal Windows Platform (UWP) making it not practicable.
The cabinet
wrapper functions are able to use various types of compression. The Enum
below lists the supported compression types.
public enum CompressionAlgorithm : UInt32
{
COMPRESS_ALGORITHM_MSZIP = 2,
COMPRESS_ALGORITHM_XPRESS = 3,
COMPRESS_ALGORITHM_XPRESS_HUFF = 4,
COMPRESS_ALGORITHM_LZMS = 5
}
Usage is very similar to the other wrappers in this library.
// Compression
//====================
// Compress Byte[] to Byte[]
Byte[] bCompressed = Cabinet.CompressStorage(bUncompressedBuffer, eAlgorithm);
// Compress File to Byte[]
Byte[] bCompressed = Cabinet.CompressStorage(sFilePath, eAlgorithm);
// Compress Byte[] to File
Cabinet.CompressStorage(bUncompressedBuffer, sFilePath, eAlgorithm);
// Compress File to File
Cabinet.CompressStorage(sFilePath, sOutputFilePath, eAlgorithm);
// Decompression
//====================
// Decompress Byte[] to Byte[]
Byte[] bDecompressed = Cabinet.DecompressStorage(bCompressedBuffer, eAlgorithm);
// Decompress File to Byte[]
Byte[] bDecompressed = Cabinet.DecompressStorage(sFilePath, eAlgorithm);
// Decompress Byte[] to File
Cabinet.DecompressStorage(bUncompressedBuffer, sFilePath, eAlgorithm);
// Decompress File to File
Cabinet.DecompressStorage(sFilePath, sOutputFilePath, eAlgorithm);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 288 | 10/28/2022 |
Initial package release.