Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

How to load a image on the windows platform? #499

Open
BlueCapo opened this issue Feb 10, 2023 · 2 comments
Open

How to load a image on the windows platform? #499

BlueCapo opened this issue Feb 10, 2023 · 2 comments

Comments

@BlueCapo
Copy link

The PlatformImage type isn't supported on Windows.
PlatformImage.FromStream(stream),it is unusable.
I can't find any solution.
Is there any other solution?

@seabluescn
Copy link

private void LoadImages()
{
IImage image = null;

#if WINDOWS

    Assembly assembly = GetType().GetTypeInfo().Assembly;
    var service = new Microsoft.Maui.Graphics.Win2D.W2DImageLoadingService();
    using (Stream stream = assembly.GetManifestResourceStream("HappySokoban.Resources.Images.box.jpg"))
    {
        image = service.FromStream(stream, ImageFormat.Jpeg);
    }        

#else

    Assembly assembly = GetType().GetTypeInfo().Assembly;
    using (Stream stream = assembly.GetManifestResourceStream("HappySokoban.Resources.Images.box.jpg"))
    {
        image = PlatformImage.FromStream(stream);
    } 

#endif
}

@TFreudi1
Copy link

TFreudi1 commented Jun 2, 2023

It also don't work with skiasharp drawbitmap on Platform-Windows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants