How do load a image stored locally in byte array using FFImageLoading for Xamarin?

Viewed 3181

I need to be able use FFImageLoading.ImageService to load a byte array I decoded from an image earlier, into a FFImageLoading.Views.ImageViewAsync object. The method ImageService.Instance.LoadImage(IImageLoaderTask task) seems to be the way but I have no idea how to set up an object of that interface and I can't find any references to using this type object on the source website.

How to load a byte[] into a ImageViewAsync object?

2 Answers

In my case, it worked like this ...

Modal.cs

 public class User 
 {
   public byte[] Avatar { get; set; }
 }

ViewModel.cs

public ImageSource Avatar
{
    get  
    {
      return ImageSource.FromStream(()=> 
        {
          return new MemoryStream(this.User.Avatar);
        });
     }
}

View.xaml

<ffimageloading:CachedImage x:Name="userAvatar" 
 Source = "{Binding Avatar}"
    Grid.Column="0" Grid.Row="0"  >

</ffimageloading:CachedImage>
Related