Files
2024-10-22 19:21:11 -07:00

32 lines
772 B
C#

namespace AssetRipper.TextureDecoder
{
internal static class ThrowHelper
{
private const int BytesPerPixel = 4;
internal static void ThrowIfNotEnoughSpace(Span<byte> output, int width, int height)
{
if (output.Length < width * height * BytesPerPixel)
{
throw new InvalidOperationException("Not enough space");
}
}
internal static void ThrowIfNotEnoughSpace(int spaceAvailable, int spaceRequired)
{
if (spaceAvailable < spaceRequired)
{
throw new InvalidOperationException($"Not enough space. {spaceRequired} is required, but only {spaceAvailable} is available");
}
}
internal static void ThrowIfNotLittleEndian()
{
if (!BitConverter.IsLittleEndian)
{
throw new PlatformNotSupportedException();
}
}
}
}