mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
31 lines
840 B
C#
31 lines
840 B
C#
using ImGuiScene;
|
|
using Lumina.Data.Files;
|
|
|
|
namespace Dalamud.Utility;
|
|
|
|
/// <summary>
|
|
/// Extensions to <see cref="TexFile"/>.
|
|
/// </summary>
|
|
public static class TexFileExtensions
|
|
{
|
|
/// <summary>
|
|
/// Returns the image data formatted for <see cref="RawDX11Scene.LoadImageRaw"/>.
|
|
/// </summary>
|
|
/// <param name="texFile">The TexFile to format.</param>
|
|
/// <returns>The formatted image data.</returns>
|
|
public static byte[] GetRgbaImageData(this TexFile texFile)
|
|
{
|
|
var imageData = texFile.ImageData;
|
|
var dst = new byte[imageData.Length];
|
|
|
|
for (var i = 0; i < dst.Length; i += 4)
|
|
{
|
|
dst[i] = imageData[i + 2];
|
|
dst[i + 1] = imageData[i + 1];
|
|
dst[i + 2] = imageData[i];
|
|
dst[i + 3] = imageData[i + 3];
|
|
}
|
|
|
|
return dst;
|
|
}
|
|
}
|