c# - BitmapSource 作为图像控件的源

标签 c# .net wpf bitmapimage

我有这个

BitmapSource  source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(),
IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

我如何使用它以某种方式将其用作WPF Image

请提供代码示例。

谢谢!

最佳答案

BitmapSource 派生自 ImageSource,因此您可以将其直接分配给 ImageSource 属性。

关于c# - BitmapSource 作为图像控件的源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9504397/

相关文章:

C# 窗口渲染 PHP

.net - IStructuralEquatable 和 IStructuralComparable 解决什么问题?

WPF MVVM 将 ComboBox 绑定(bind)到 Datagrid 所选项目

c# - WPF 数据网格和 Tab 键

c# - @前缀对C#中的字符串文字有什么作用

wpf - 绑定(bind)到 XAML 中的 ICollectionView.Count 属性

c# - Ninject 的 Httpcontext.Session 始终为 null

c# - 如何将使用 EntityFramework 4.0 的 C# 应用程序升级到 4.3.1

C# - Big Endian 中的二进制读取器?

C# 指针和值类型变量的重定位