29 lines
643 B
C#
29 lines
643 B
C#
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);
|
|
}
|
|
} |