mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-08 18:46:04 +03:00
Add ZStd Support - Uses ZstdSharp.Port
This commit is contained in:
parent
7f78a971f9
commit
60d5318348
3 changed files with 17 additions and 1 deletions
|
@ -26,4 +26,8 @@
|
|||
<None Include="../../LICENSE" Pack="true" PackagePath="" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ZstdSharp.Port" Version="0.8.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -46,6 +46,12 @@ internal static partial class Helpers
|
|||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
|
||||
internal static uint[] DecompressZStd(MemoryStream stream)
|
||||
{
|
||||
using var decompressedStream = new ZstdSharp.DecompressionStream(stream);
|
||||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
|
||||
internal static uint[] ReadBytesAsInt32Array(byte[] bytes)
|
||||
{
|
||||
var intArray = new uint[bytes.Length / 4];
|
||||
|
|
|
@ -78,7 +78,7 @@ public abstract partial class TmxReaderBase
|
|||
{
|
||||
DataCompression.GZip => DecompressGZip(bytes),
|
||||
DataCompression.ZLib => DecompressZLib(bytes),
|
||||
DataCompression.ZStd => throw new NotSupportedException("ZStd compression is not supported."),
|
||||
DataCompression.ZStd => DecompressZStd(bytes),
|
||||
_ => throw new XmlException("Invalid compression")
|
||||
};
|
||||
|
||||
|
@ -117,4 +117,10 @@ public abstract partial class TmxReaderBase
|
|||
using var decompressedStream = new ZLibStream(stream, CompressionMode.Decompress);
|
||||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
|
||||
internal static uint[] DecompressZStd(MemoryStream stream)
|
||||
{
|
||||
using var decompressedStream = new ZstdSharp.DecompressionStream(stream);
|
||||
return ReadMemoryStreamAsInt32Array(decompressedStream);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue