botw-toolset/IO/HGHT.cs
Chev a1a83285f8 Migrate from .NET Framework 4.8 to .NET 5
Also compress Resources/Icons image files, and remove unused entry in App.xaml
2021-01-18 23:33:46 -08:00

35 lines
914 B
C#

using System.IO;
namespace BOTWToolset.IO
{
/// <summary>
/// Contains data for .hght files.
/// </summary>
public class HGHT
{
public ushort[] Heights;
/// <summary>
/// Retrieves a <see cref="HGHT"/> array from a set of bytes.
/// </summary>
/// <param name="bytes">The array of bytes to read.</param>
/// <returns><see cref="HGHT"/> array.</returns>
public static HGHT FromBytes(byte[] bytes)
{
using (var r = new BinaryReader(new MemoryStream(bytes)))
{
HGHT h = new HGHT
{
Heights = new ushort[r.BaseStream.Length / 2]
};
for (int i = 0; i < h.Heights.Length; i++)
{
h.Heights[i] = r.ReadUInt16();
}
return h;
}
}
}
}