skyscraper8/GUIs/skyscraper8.UI.ImGui/ByteArrayExtensions.cs
feyris-tan ef86554f9a Import
2025-05-12 22:09:16 +02:00

27 lines
721 B
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SDL2Demo
{
internal static class ByteArrayExtensions
{
private static byte[] buffer = new byte[4];
[DebuggerStepThrough]
public static uint ReadUInt32BE(this byte[] stream, int offset)
{
buffer[0] = stream[offset + 0];
buffer[1] = stream[offset + 1];
buffer[2] = stream[offset + 2];
buffer[3] = stream[offset + 3];
if (BitConverter.IsLittleEndian)
Array.Reverse(buffer, 0, 4);
return BitConverter.ToUInt32(buffer, 0);
}
}
}