Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

BLOB to Image Binding

$
0
0

I have to bind images from a SQLite database. The images are stores as BLOB (png file).

var image = new Image
 {
          HorizontalOptions = LayoutOptions.Start,
          WidthRequest = 40,
          HeightRequest = 40
 };

 var bnd = new Binding("Image", BindingMode.Default, new ArrayToImageConverter());
 image.SetBinding(Image.SourceProperty, bnd);

How to define an "ArrayToImageConverter"

        public abstract class ArrayToImageConverter : IValueConverter
            {
               public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
               {
                     byte[] bmp = value as byte[];
                     if (bmp == null)
                         return null;

                   return new StreamImageSource 
                   {
                         Stream =  ?????
                    };
               }
                public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
               {
                     throw new System.NotImplementedException();
                }
            }

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>