mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add support for loading images for use in ImGui windows
This commit is contained in:
parent
c95b39b6e8
commit
cc676a25f5
3 changed files with 43 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,22 @@ namespace Dalamud.Interface
|
|||
this.interfaceManager.OnDraw -= OnDraw;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads an image from the specified file.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The full filepath to the image.</param>
|
||||
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
||||
public TextureWrap LoadImage(string filePath) =>
|
||||
this.interfaceManager.LoadImage(filePath);
|
||||
|
||||
/// <summary>
|
||||
/// Loads an image from a byte stream, such as a png downloaded into memory.
|
||||
/// </summary>
|
||||
/// <param name="imageData">A byte array containing the raw image data.</param>
|
||||
/// <returns>A <see cref="TextureWrap"/> object wrapping the created image. Use <see cref="TextureWrap.ImGuiHandle"/> inside ImGui.Image()</returns>
|
||||
public TextureWrap LoadImage(byte[] imageData) =>
|
||||
this.interfaceManager.LoadImage(imageData);
|
||||
|
||||
private void OnDraw() {
|
||||
ImGui.PushID(this.namespaceName);
|
||||
OnBuildUi?.Invoke();
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 09dde468ea8a6a1729fc8dd334379d1514264742
|
||||
Subproject commit 4b78854fcbf60775a7c34d73c83ad69115ce4587
|
||||
Loading…
Add table
Add a link
Reference in a new issue