.netsvgxamarin.formsffimageloadingesri-arc-engine

Xamarin.Forms FFImageLoading SVGs to ESRI RunTimeImage


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.


Solution

  • 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);