扩展方法
public static class ext
{
public static BitmapImage ToBitmapImage(this Bitmap bitmap)
{
var stream = new InMemoryRandomAccessStream();
bitmap.Save(stream.AsStreamForWrite(), ImageFormat.Png);
stream.Seek(0);
BitmapImage bi = new BitmapImage();
bi.SetSource(stream);
return bi;
}
}
OpenCVSharp
Mat->BitmapImage并显示
byte[] bytes=mat512.ToBytes();
using (var ms=new InMemoryRandomAccessStream())
{
var bi = new BitmapImage();
await ms.WriteAsync(bytes.AsBuffer());
ms.Seek(0);
await bi.SetSourceAsync(ms);
img4.Source=bi;
}
end