2023-10-02 23:17:30 +00:00
|
|
|
using Raylib_cs;
|
|
|
|
using ImageMagick;
|
|
|
|
|
|
|
|
namespace Shoko;
|
|
|
|
|
|
|
|
[MediaType("image/*")]
|
|
|
|
class MagickMediaHandler : ImageMediaHandler
|
|
|
|
{
|
|
|
|
public MagickMediaHandler(ProtoHandler content)
|
|
|
|
{
|
|
|
|
Content = content;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Load()
|
|
|
|
{
|
2023-10-12 18:29:32 +00:00
|
|
|
Title = Content.URL.AbsolutePath;
|
2023-10-02 23:17:30 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|