add format for textures in analysis (#55)

* add format for textures in analysis

* requested changes

* Update CharacterAnalyzer.cs
This commit is contained in:
Cara
2023-07-21 23:01:03 +09:30
committed by GitHub
parent 71c510b0f4
commit 221deb64c6
2 changed files with 39 additions and 1 deletions

View File

@@ -5,6 +5,8 @@ using MareSynchronos.Services.Mediator;
using MareSynchronos.UI;
using MareSynchronos.Utils;
using Microsoft.Extensions.Logging;
using Lumina.Data;
using Lumina.Data.Files;
namespace MareSynchronos.Services;
@@ -176,5 +178,30 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
}
public long OriginalSize { get; private set; } = OriginalSize;
public long CompressedSize { get; private set; } = CompressedSize;
public Lazy<string> Format = new(() =>
{
switch (FileType)
{
case "tex":
{
try
{
using var stream = new FileStream(FilePaths[0], FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(stream);
reader.BaseStream.Position = 4;
var format = (TexFile.TextureFormat)reader.ReadInt32();
return format.ToString();
}
catch
{
return "Unknown";
}
}
default:
return string.Empty;
}
});
}
}