byte[] 转图片
作者:互联网
字符串转byte[]
byte[] by = ConVert.FromBase64String(st);
//byte[] 转图片
class BinaryImageConverter : IValueConverter{ object IValueConverter.Convert( object value,Type targetType,object parameter,System.Globalization.CultureInfo culture )
{
if(value != null && value is byte[])
{
byte[] bytes = value as byte[]; MemoryStream stream = new MemoryStream( bytes ); BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit(); return image;
} return null; } object IValueConverter.ConvertBack( object value,Type targetType,culture )
{
throw new Exception("该方法不能执行"); }
}
class BinaryImageConverter : IValueConverter{ object IValueConverter.Convert( object value,Type targetType,object parameter,System.Globalization.CultureInfo culture )
{
if(value != null && value is byte[])
{
byte[] bytes = value as byte[]; MemoryStream stream = new MemoryStream( bytes ); BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit(); return image;
} return null; } object IValueConverter.ConvertBack( object value,Type targetType,culture )
{
throw new Exception("该方法不能执行"); }
}
标签:IValueConverter,image,object,value,new,byte,图片 来源: https://www.cnblogs.com/MZ-A/p/12119187.html