Microsoft.Maui.Graphics icon indicating copy to clipboard operation
Microsoft.Maui.Graphics copied to clipboard

Can it support SVG and other vector graph formats?

Open sharpwood opened this issue 3 years ago • 12 comments

sharpwood avatar Jun 16 '21 12:06 sharpwood

Current platform-independent Svg support in .Net is https://github.com/wieslawsoltes/Svg.Skia . If Maui.Graphics takes over from SkiaSharp as the main .Net platform-independent graphics abstraction then I would assume this lib will get ported to Maui.Graphics. You can ask there though to guage interest.

charlesroddie avatar Jun 20 '21 16:06 charlesroddie

Pinging @wieslawsoltes .

charlesroddie avatar Jun 20 '21 16:06 charlesroddie

Current platform-independent Svg support in .Net is https://github.com/wieslawsoltes/Svg.Skia . If Maui.Graphics takes over from SkiaSharp as the main .Net platform-independent graphics abstraction then I would assume this lib will get ported to Maui.Graphics. You can ask there though to guage interest.

It really depends on what API will be supported in Microsoft.Maui.Graphics. Svg.Skia for full feature set supported required a lot of SkiaSharp apis. If you want just basic subset of Svg (no filter effects etc.) that it should be pretty easy to add. Svg.Skia has special abstraction layer modeled so it's easy to add new targets (if they have necessary features).

wieslawsoltes avatar Jun 20 '21 19:06 wieslawsoltes

hope svg.skia can provide a preliminary SVG support for Maui @wieslawsoltes .

sharpwood avatar Sep 19 '21 13:09 sharpwood

@charlesroddie

If Maui.Graphics takes over from SkiaSharp as the main .Net platform-independent graphics abstraction...

That's a big "if". The advantage of Skia is its universal support - extending beyond .Net circles.

I don't see how or why there would be a platform that Maui.Graphics supports, that isn't already supported by Skia. To me, for the foreseeable future, it makes more sense to leverage Skia, make Maui-based layers on it, to mix with other layers that go direct to Skia, than to port-and-maintain stuff that already works well there.

Even in environments where Maui can render straight to a frame buffer without needing Skia as an intermediary, can point Skia at the same frame buffer, let Skg.Skia work as-is. Or am I missing something?

My two cents.

ToolmakerSteve avatar Dec 11 '21 02:12 ToolmakerSteve

I like Skia - nicer API to work with. Possible major advantage of Maui.Graphics is the lack of need to deploy a 5MB library to user systems. For web this seems critical to me: with good linking/AOT, Skia could easily dominate download size of dotnet wasm apps in future. But not completely sure - maybe it's possible to deploy SkiaSharp to web without deploying Skia, when using a browser which has Skia integrated?

charlesroddie avatar Dec 11 '21 10:12 charlesroddie

Good point.

ToolmakerSteve avatar Dec 16 '21 00:12 ToolmakerSteve

image

wieslawsoltes avatar Jan 09 '22 12:01 wieslawsoltes

Is this still the best way to go about rendering an SVG image directly onto a MAUI GraphicsView? Other possibilities, and potential ongoing work, were mentioned in the thread.

Over a half year later, is Svg.Skia still the best way to go? Or, is something in the MS ecosystem evolving to displace it?

Also, @wieslawsoltes, is there any code-behind that accompanies your most recent post? If so, can you share it? Thanks.

techfan101 avatar Jul 29 '22 13:07 techfan101

It seems to me that this is currently the best solution for using SVG's in MAUI views. @wieslawsoltes, Could you share the code of how you were able to do this in MAUI? What does SvgDrawable look like? I don't understand how you are using Svg.Skia, are you still using IDrawable?

DclearEE avatar Aug 14 '22 22:08 DclearEE

@techfan101 @DclearEE were you able to get access to the rest of the code for the SvgDrawable?

Lina-AI avatar Dec 06 '23 16:12 Lina-AI

@techfan101 @DclearEE were you able to get access to the rest of the code for the SvgDrawable?

I ended up using SkiaSharp to do everything with SVGs. Using Skia was similar to Maui.graphics but it had more capabilities. I also switched to using the Uno Platform to build my app instead of Maui. I haven’t revisited Maui or its graphics library since.

DclearEE avatar Dec 09 '23 20:12 DclearEE