Created
July 27, 2015 02:53
-
-
Save programmation/4e4131924c02aee4fc1d to your computer and use it in GitHub Desktop.
Convert byte array to ImageSource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://forums.xamarin.com/discussion/comment/89964/#Comment_89964 | |
namespace Core.Converters | |
{ | |
public class ByteArrayToImageSource : IValueConverter | |
{ | |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
if (value == null || value is DBNull) | |
return null; | |
var bArray = (byte[]) value; | |
var imgsrc = ImageSource.FromStream(() => { | |
var ms = new MemoryStream(bArray); | |
ms.Position = 0; | |
return ms; | |
}); | |
return imgsrc; | |
} | |
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment