mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-13 05:35:24 +00:00
35 lines
904 B
C#
35 lines
904 B
C#
using System;
|
|
using ICSharpCode.SharpZipLib.Zip.Compression;
|
|
|
|
namespace BurnOutSharp.Compression
|
|
{
|
|
public class MSZIP_zlib
|
|
{
|
|
#region Instance Variables
|
|
|
|
/// <summary>
|
|
/// Inflater to be shared between blocks
|
|
/// </summary>
|
|
private readonly Inflater _inflater = new Inflater(noHeader: true);
|
|
|
|
#endregion
|
|
|
|
#region Decompressiom
|
|
|
|
/// <summary>
|
|
/// Decompress MSZIP data block
|
|
/// </summary>
|
|
public byte[] DecompressMSZIPData(byte[] data, bool previousBlock = false)
|
|
{
|
|
if (previousBlock)
|
|
_inflater.Reset();
|
|
|
|
_inflater.SetInput(buffer: data, 2, data.Length - 2);
|
|
byte[] outputData = new byte[128 * 1024];
|
|
int read = _inflater.Inflate(outputData);
|
|
return outputData.AsSpan(0, read).ToArray();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |