mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-12 18:07:28 -10:00
32 lines
772 B
C#
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();
|
|
}
|
|
}
|
|
}
|
|
}
|