Xamarin.Forms FFImageLoading SVGs to ESRI RunTimeImage

270 Views Asked by At

Converting an SVG to a RunTimeImage.

Essentially I'm trying to find a way to access the stream before it gets wrapped in an SVGImageSource so I can feed the byte array into the ArcGis RunTimeImage provided by Esri.

SVG's are kept in a PCL.

2

There are 2 best solutions below

0
On BEST ANSWER

I was not able to figure this out for the time being, but the following code excerpt is a work around accessing the drawable folder of your android project using a png version of the image.

            int resourceId = Android.App.Application.Context.Resources.GetIdentifier("atlaspinorange", "drawable", "Atlas.Locations");
        var icon = Android.Graphics.BitmapFactory.DecodeResource(Android.App.Application.Context.Resources, resourceId);
        var stream = new System.IO.MemoryStream();
        icon.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 50, stream);
        byte[] byteArray = stream.ToArray();
        var image = new Esri.ArcGISRuntime.UI.RuntimeImage(byteArray);
        mapView.LocationDisplay.CourseSymbol = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol(image);
        mapView.LocationDisplay.DefaultSymbol = new Esri.ArcGISRuntime.Symbology.PictureMarkerSymbol(image);
0
On

Are you looking for this

ImageService.Instance.LoadCompiledResource("yourFile.svg").WithCustomDataResolver(new SvgDataResolver(200,200)).AsPNGStreamAsync();

?