From a80218d741259633fb27dcaa585e77d2225ca9a1 Mon Sep 17 00:00:00 2001
From: meli <57847713+ff-meli@users.noreply.github.com>
Date: Fri, 3 Apr 2020 16:42:20 -0700
Subject: [PATCH] expose imguiscene method to load textures from raw pixel
data; underlying handling may change, but UIBuilder api can probably remain
this way
---
Dalamud/Interface/InterfaceManager.cs | 13 +++++++++++++
Dalamud/Interface/UiBuilder.cs | 11 +++++++++++
lib/ImGuiScene | 2 +-
3 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/Dalamud/Interface/InterfaceManager.cs b/Dalamud/Interface/InterfaceManager.cs
index 54b3548ac..83d496efa 100644
--- a/Dalamud/Interface/InterfaceManager.cs
+++ b/Dalamud/Interface/InterfaceManager.cs
@@ -148,6 +148,19 @@ namespace Dalamud.Interface
return null;
}
+ public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels)
+ {
+ try
+ {
+ return this.scene?.LoadImageRaw(imageData, width, height, numChannels) ?? null;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to load image from raw data");
+ }
+ 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 d07512c23..5ad397845 100644
--- a/Dalamud/Interface/UiBuilder.cs
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -58,6 +58,17 @@ namespace Dalamud.Interface
public TextureWrap LoadImage(byte[] imageData) =>
this.interfaceManager.LoadImage(imageData);
+ ///
+ /// Loads an image from raw unformatted pixel data, with no type or header information. To load formatted data, use .
+ ///
+ /// A byte array containing the raw pixel data.
+ /// The width of the image contained in .
+ /// The height of the image contained in .
+ /// The number of channels (bytes per pixel) of the image contained in . This should usually be 4.
+ /// A object wrapping the created image. Use inside ImGui.Image()
+ public TextureWrap LoadImageRaw(byte[] imageData, int width, int height, int numChannels) =>
+ this.interfaceManager.LoadImageRaw(imageData, width, height, numChannels);
+
///
/// Event that is fired when the plugin should open its configuration interface.
///
diff --git a/lib/ImGuiScene b/lib/ImGuiScene
index d0c03cd31..b096e5b2e 160000
--- a/lib/ImGuiScene
+++ b/lib/ImGuiScene
@@ -1 +1 @@
-Subproject commit d0c03cd31dac7a3eede52a467ef81def69f87ef9
+Subproject commit b096e5b2e9826525394a0c00b987aad1f2c4eccb