byte[] 转图片
Posted mz-a
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了byte[] 转图片相关的知识,希望对你有一定的参考价值。
字符串转byte[]
byte[] by = ConVert.FromBase64String(st);
//byte[] 转图片
class BinaryImageConverter : IValueConverter{
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[];
{
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();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
return image;
}
}
return null; }
object IValueConverter.ConvertBack( object value,Type targetType,culture )
{
throw new Exception("该方法不能执行");
{
throw new Exception("该方法不能执行");
}
}
}
以上是关于byte[] 转图片的主要内容,如果未能解决你的问题,请参考以下文章