mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-17 05:17:42 +01:00
Add ITextureProvider.GetFromManifestResource(Assembly,string)
This commit is contained in:
parent
b52d4724e9
commit
cc756c243c
5 changed files with 327 additions and 35 deletions
|
|
@ -1,3 +1,7 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Dalamud.Memory;
|
||||
|
||||
using ImGuiScene;
|
||||
using Lumina.Data.Files;
|
||||
|
||||
|
|
@ -28,4 +32,25 @@ public static class TexFileExtensions
|
|||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/// <summary>Determines if the given data is possibly a <see cref="TexFile"/>.</summary>
|
||||
/// <param name="data">The data.</param>
|
||||
/// <returns><c>true</c> if it should be attempted to be interpreted as a <see cref="TexFile"/>.</returns>
|
||||
internal static unsafe bool IsPossiblyTexFile2D(ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (data.Length < Unsafe.SizeOf<TexFile.TexHeader>())
|
||||
return false;
|
||||
fixed (byte* ptr = data)
|
||||
{
|
||||
ref readonly var texHeader = ref MemoryHelper.Cast<TexFile.TexHeader>((nint)ptr);
|
||||
if ((texHeader.Type & TexFile.Attribute.TextureTypeMask) != TexFile.Attribute.TextureType2D)
|
||||
return false;
|
||||
if (!Enum.IsDefined(texHeader.Format))
|
||||
return false;
|
||||
if (texHeader.Width == 0 || texHeader.Height == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue