dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.07k stars 1.17k forks source link

SVG support for Image.ImageSource #86

Open bhood-zorus opened 5 years ago

bhood-zorus commented 5 years ago

SVG is a perfect match for WPF, but there's no way to display one without either using a third party library or converting it to XAML.

heltonbiker commented 5 years ago

Besides an SvgSource class, it would be awesome to have SvgBrush and SvgDrawing too, etc.

wyshmily commented 5 years ago

and what about gif support ?

weltkante commented 5 years ago

You already have DrawingImage, DrawingBrush and GeometryDrawing which are vector based and can cover most simple SVG graphics, you just have to write a loader, no need to convert to XAML first, you can use the WPF primitives directly. Of course it would be great if it were builtin, I think UWP has support, it would be great if post-3.0 WPF could be updated to be at least on par with what UWP supports.

GIF is just an image format, it should already work through normal image sources/brushes/drawings given there's an appropriate decoder (I think there is but didn't check), or do you mean GIF animations? If there is no GIF decoder or if you want animations please open a separate issue.

bhood-zorus commented 5 years ago

@weltkante The "great if it were builtin" bit of your post is exactly the reason I made this issue. It's baffling that WPF didn't come with SVG support out of the box.

AraHaan commented 2 years ago

I also agree, however what about other things with the SVG loader as well? Like for example if the SVG has paths specifying a specific color embedded in the svg data but you want to have the loader substitute that color with another one (take RebeccaPurple to replace black for example)?

lindexi commented 2 years ago

How about https://github.com/ElinamLLC/SharpVectors

AraHaan commented 2 years ago

That does svg to xaml, which this issue is trying to avoid the need to do such thing.

Also the conversion to xaml is not always the best option because what if it also includes hidden paths from the svg image and displays them in your wpf code?

As such I am considering this might be the better option to bring into WPF built in eventually: https://github.com/dotnetprojects/SVGImage