DisplayName
DisplayName

Reputation: 306

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.

Upvotes: 0

Views: 258

Answers (2)

Daniel Luberda
Daniel Luberda

Reputation: 7454

Are you looking for this

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

?

Upvotes: 1

DisplayName
DisplayName

Reputation: 306

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

Upvotes: 0

Related Questions