Use ImageMagick to support even more image formats
This commit is contained in:
parent
cf8e42587b
commit
fcca47458f
|
@ -16,8 +16,12 @@ class ImageMediaHandler : MediaHandler
|
||||||
["image/qoi"] = ".qoi",
|
["image/qoi"] = ".qoi",
|
||||||
["image/x-qoi"] = ".qoi",
|
["image/x-qoi"] = ".qoi",
|
||||||
};
|
};
|
||||||
Texture2D Texture;
|
protected Texture2D Texture;
|
||||||
float Zoom = 1;
|
protected float Zoom = 1;
|
||||||
|
|
||||||
|
public ImageMediaHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
public ImageMediaHandler(ProtoHandler content)
|
public ImageMediaHandler(ProtoHandler content)
|
||||||
{
|
{
|
||||||
Content = content;
|
Content = content;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
using Raylib_cs;
|
||||||
|
using ImageMagick;
|
||||||
|
|
||||||
|
namespace Shoko;
|
||||||
|
|
||||||
|
[MediaType("image/*")]
|
||||||
|
class MagickMediaHandler : ImageMediaHandler
|
||||||
|
{
|
||||||
|
public MagickMediaHandler(ProtoHandler content)
|
||||||
|
{
|
||||||
|
Content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
|
{
|
||||||
|
using(var magic = new MagickImage(Content.Content))
|
||||||
|
{
|
||||||
|
magic.Format = MagickFormat.Png;
|
||||||
|
var image = Raylib.LoadImageFromMemory(".png", magic.ToByteArray());
|
||||||
|
Texture = Raylib.LoadTextureFromImage(image);
|
||||||
|
Raylib.UnloadImage(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~MagickMediaHandler()
|
||||||
|
{
|
||||||
|
Raylib.UnloadTexture(Texture);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
<PackageReference Include="Raylib-cs" Version="4.5.0.4" />
|
<PackageReference Include="Raylib-cs" Version="4.5.0.4" />
|
||||||
<PackageReference Include="rlImgui-cs" Version="1.0.3" />
|
<PackageReference Include="rlImgui-cs" Version="1.0.3" />
|
||||||
<PackageReference Include="ImGui.NET" Version="1.89.9.2" />
|
<PackageReference Include="ImGui.NET" Version="1.89.9.2" />
|
||||||
|
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
Loading…
Reference in New Issue