diff --git a/Dalamud/Interface/InterfaceManager.cs b/Dalamud/Interface/InterfaceManager.cs index 67e3a0346..faae2030d 100644 --- a/Dalamud/Interface/InterfaceManager.cs +++ b/Dalamud/Interface/InterfaceManager.cs @@ -109,6 +109,32 @@ namespace Dalamud.Interface this.presentHook.Dispose(); } + public TextureWrap LoadImage(string filePath) + { + try + { + return this.scene?.LoadImage(filePath) ?? null; + } + catch (Exception ex) + { + Log.Error(ex, $"Failed to load image from {filePath}"); + } + return null; + } + + public TextureWrap LoadImage(byte[] imageData) + { + try + { + return this.scene?.LoadImage(imageData) ?? null; + } + catch (Exception ex) + { + Log.Error(ex, "Failed to load image from memory"); + } + return null; + } + private IntPtr PresentDetour(IntPtr swapChain, uint syncInterval, uint presentFlags) { if (this.scene == null) diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs index 5e47b3fdb..9c1a76016 100644 --- a/Dalamud/Interface/UiBuilder.cs +++ b/Dalamud/Interface/UiBuilder.cs @@ -26,6 +26,22 @@ namespace Dalamud.Interface this.interfaceManager.OnDraw -= OnDraw; } + /// + /// Loads an image from the specified file. + /// + /// The full filepath to the image. + /// A object wrapping the created image. Use inside ImGui.Image() + public TextureWrap LoadImage(string filePath) => + this.interfaceManager.LoadImage(filePath); + + /// + /// Loads an image from a byte stream, such as a png downloaded into memory. + /// + /// A byte array containing the raw image data. + /// A object wrapping the created image. Use inside ImGui.Image() + public TextureWrap LoadImage(byte[] imageData) => + this.interfaceManager.LoadImage(imageData); + private void OnDraw() { ImGui.PushID(this.namespaceName); OnBuildUi?.Invoke(); diff --git a/lib/ImGuiScene b/lib/ImGuiScene index 09dde468e..4b78854fc 160000 --- a/lib/ImGuiScene +++ b/lib/ImGuiScene @@ -1 +1 @@ -Subproject commit 09dde468ea8a6a1729fc8dd334379d1514264742 +Subproject commit 4b78854fcbf60775a7c34d73c83ad69115ce4587