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

IImage.Save (SkiaImage) not implemented #437

Open
StuffOfInterest opened this issue May 29, 2022 · 8 comments
Open

IImage.Save (SkiaImage) not implemented #437

StuffOfInterest opened this issue May 29, 2022 · 8 comments

Comments

@StuffOfInterest
Copy link

StuffOfInterest commented May 29, 2022

This is a follow-on from #436. Building some code to replace System.Drawing.Common image manipulation for a ASP.NET 6 website running on Windows. Tried to take an IImage over to a byte array via a memory stream as shown here. The exact code doing this work is:

public static byte[] ConvertImageToByteArray(IImage imageToConvert, ImageFormat formatOfImage)
{
    byte[] ret;

    using (var ms = new MemoryStream())
    {
        imageToConvert.Save(ms, formatOfImage);
        ret = ms.ToArray();
    }

    return ret;
}

The IImage was extracted from a byte array using SkiaImage as shown in #436. The call to .Save() ends up with a PlatformNotImplementedException.

image

The same exception is thrown if the using block above is replaced with the AsBytes extension method:

ret = imageToConvert.AsBytes(formatOfImage);

Being that I'm using version 6.0.300 of both the Microsoft.Maui.Graphics and Microsoft.Maui.Graphics.Skia NuGet packages, I thought MAUI was up to feature complete status. Did this method get overlooked is is Skia not intended to support Windows?

@sharpSteff
Copy link

IMO it's not ok to tell devs to migrate from System.Drawing.Common to Microsoft.Maui.Graphics when this lib is clearly not ready for production

@RChrisCoble
Copy link

We're just using SkiaSharp directly, as that's the primary rendering engine behind MAUI.Graphics anyway. Our primary UC has us using SkiaSharp in Blazor WASM (with fantastic success), then we'll move onto other platforms. Skia/SkiaSharp supports as many platforms as you would need. If MAUI.Graphics gets its act together and additionally supports Blazor Server (which is required for Blazor Hybrid support) that would give us a compelling reason to move off of SkiaSharp.

@sharpSteff
Copy link

Then what's the purpose of Microsoft.Maui.Graphics, when it's using SkipSharp any way?

@RChrisCoble
Copy link

It's an abstraction layer, allowing other rendering implementations to be used when appropriate in the future. It may not make sense for MAUI to require delivery of Google's Skia and MS's SkiaSharp on every platform MAUI wants to support.

@sharpSteff
Copy link

It's an abstraction layer, allowing other rendering implementations to be used when appropriate in the future. It may not make sense for MAUI to require delivery of Google's Skia and MS's SkiaSharp on every platform MAUI wants to support.

Yes exactly, e.g on windows. GDI+ is fast and solid. It's a mess that there is no GDI+ Implementation yet. (Source code is available but not published as a Nuget)

@swharden
Copy link
Contributor

Are there plans to publish the GDI package?

I'd be more inclined to use and contribute to it if it were published on NuGet with the other packages

@sharpSteff
Copy link

sharpSteff commented Oct 18, 2022

@swharden I've created an issue for this #489

@lindexi
Copy link
Member

lindexi commented Oct 26, 2022

@StuffOfInterest #475

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

5 participants