Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: allowed svg rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 8, 2023
1 parent fc9f02f commit 65bb318
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using ECommons.ImGuiMethods;
using ImGuiScene;
using Svg;
using System.Drawing.Imaging;

namespace RotationSolver.Basic.Data;

Expand Down Expand Up @@ -74,6 +76,24 @@ public enum IconType : byte
/// </summary>
public static class IconSet
{
/// <summary>
/// Init for svg rendering.
/// </summary>
public static void InIt()
{
ThreadLoadImageHandler.AddConversionToBitmap(SvgToPng);
}

private static byte[] SvgToPng(byte[] data)
{
using var stream = new MemoryStream(data);
using var outStream = new MemoryStream();
var svgDocument = SvgDocument.Open<SvgDocument>(stream);
using var bitmap = svgDocument.Draw();
bitmap.Save(outStream, ImageFormat.Png);
return outStream.ToArray();
}

/// <summary>
/// Get Texture form texture.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions RotationSolver.Basic/RotationSolver.Basic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<PackageReference Include="Svg" Version="3.4.4" />
<None Update="README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/RotationSolverPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public RotationSolverPlugin(DalamudPluginInterface pluginInterface)
{
ECommonsMain.Init(pluginInterface, this, Module.DalamudReflector, Module.ObjectFunctions);
ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out _);
IconSet.InIt();

//Init!
Clipper.InflatePaths(new PathsD(new PathD[] { Clipper.MakePath(new double[] {0, 0, 1, 1 }) }), 0, JoinType.Round, EndType.Joined);
Expand Down

0 comments on commit 65bb318

Please sign in to comment.