0

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.

Blauharley
  • 4,186
  • 6
  • 28
  • 47
DisplayName
  • 196
  • 3
  • 12
  • FFImageLoading is open source. If you want to make a change to it's behavior you can fork it, do a PR, or just create your own local copy – Jason Jan 05 '18 at 20:32
  • Thank you for the suggestion. Ill probably just go with a png version of the image for the time being. I would prefer not to have to maintain a version of the package if possible. – DisplayName Jan 05 '18 at 21:33

2 Answers2

1

Are you looking for this

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

?

Daniel Luberda
  • 7,374
  • 1
  • 32
  • 40
0

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);
DisplayName
  • 196
  • 3
  • 12