muak / SvgImageSource

Custom ImageSource that will become able to show svg image for Xamarin.Forms
MIT License
62 stars 11 forks source link

Button.Image and ToolbarItem.Icon? #2

Closed rraallvv closed 6 years ago

rraallvv commented 6 years ago

Does SvgImageSource support Button.Image and ToolbarItem.Icon?

muak commented 6 years ago

@rraallvv I'm sorry that this library doesn't support ToolbarItem.Icon and Button.Image because Xamarin.Forms defines those properties as FileImageSource. SvgImageSource must be used by a property defined as ImageSource on Xamarin.Forms.

I hope that Xamarin.Forms will change FileImageSource To ImageSource.

rraallvv commented 6 years ago

@muak thanks for your quick reply.

Is there a way with SvgImageSource to convert SVG images to PNG or JPG an store them somewhere in the filesystem?

I'm asking because I was able to make ToolbarItem.Icon to load a rasterized file stored in the cache, and Button.Image has the problem that it only accepts drawables or resources, but using a custom renderer that limitation could be circumvented too.

muak commented 6 years ago

@rraallvv SvgImageSource hasn't the function converting an image. But an SVG image can be converted to PNG/JPG and save it on each platform. I have ever considered saving as png/jpg files once such as what you said. However, thinking performance, I became to think it better that we use png/jpg files from the beginning.

rraallvv commented 6 years ago

@muak it seems trying to handle SVG image as resources and rasterizing when it's needed isn't worth it, thanks for pointing that out.

I finally settled for a NuGet package to build all PNG files from SVG images. It has the benefit that SVG files aren't shipped with the application.

muak commented 6 years ago

@rraallvv That package is very good! It is a nice idea that png/jpg images are created and arranged when building. I think that I will try it too!

Thank you.