diff --git a/Media/ImageMediaHandler.cs b/Media/ImageMediaHandler.cs index 9de0d5c..5b90e5e 100644 --- a/Media/ImageMediaHandler.cs +++ b/Media/ImageMediaHandler.cs @@ -16,8 +16,12 @@ class ImageMediaHandler : MediaHandler ["image/qoi"] = ".qoi", ["image/x-qoi"] = ".qoi", }; - Texture2D Texture; - float Zoom = 1; + protected Texture2D Texture; + protected float Zoom = 1; + + public ImageMediaHandler() + { + } public ImageMediaHandler(ProtoHandler content) { Content = content; diff --git a/Media/MagickMediaHandler.cs b/Media/MagickMediaHandler.cs new file mode 100644 index 0000000..9635cae --- /dev/null +++ b/Media/MagickMediaHandler.cs @@ -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); + } +} \ No newline at end of file diff --git a/shoko.csproj b/shoko.csproj index 76478f7..2123e1e 100644 --- a/shoko.csproj +++ b/shoko.csproj @@ -18,6 +18,7 @@ +