1
votes

I have an API binded to Xamarin.Android part of project, that returns image as Drawable object. I need to show this image in UI, that is written in Xamarin.Forms. The problem is that Image control there accepts only ImageSource as a source. How can I wrap Drawable into ImageSource object?

1
Did you find a solution? - Benoit

1 Answers

2
votes

You can do like this:

byte[] bytes = drawable.ToArray();
var iamgeSource = ImageSource.FromStream(() => new MemoryStream(bytes));