Reputation: 223
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?
Upvotes: 2
Views: 1068
Reputation: 1545
You can do like this:
byte[] bytes = drawable.ToArray();
var iamgeSource = ImageSource.FromStream(() => new MemoryStream(bytes));
Upvotes: 1