|
|
@@ -470,6 +470,7 @@ namespace SharpGLTF.Memory
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
+ [System.Diagnostics.DebuggerDisplay("{PixelWidth}x{PixelHeight}x{PixelDepth}")]
|
|
|
readonly struct Ktx2Header
|
|
|
{
|
|
|
// http://github.khronos.org/KTX-Specification/
|
|
|
@@ -487,10 +488,12 @@ namespace SharpGLTF.Memory
|
|
|
public readonly UInt32 LevelCount;
|
|
|
public readonly UInt32 SupercompressionScheme;
|
|
|
|
|
|
- public static bool TryGetHeader(IReadOnlyList<Byte> data, out Ktx2Header header)
|
|
|
+ public static unsafe bool TryGetHeader(IReadOnlyList<Byte> data, out Ktx2Header header)
|
|
|
{
|
|
|
- if (data.Count < 12) { header = default; return false; }
|
|
|
- header = System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, Ktx2Header>(data.ToArray())[0];
|
|
|
+ if (!(data is Byte[] array)) array = data?.ToArray() ?? Array.Empty<Byte>();
|
|
|
+
|
|
|
+ if (data.Count < sizeof(Ktx2Header)) { header = default; return false; }
|
|
|
+ header = System.Runtime.InteropServices.MemoryMarshal.Cast<Byte, Ktx2Header>(array)[0];
|
|
|
return true;
|
|
|
}
|
|
|
|