【问题标题】:How to load a bitmap to ImageSource real time in wpf?如何在 wpf 中实时将位图加载到 ImageSource?
【发布时间】:2012-12-07 02:28:04
【问题描述】:

我知道如何将位图从Load a WPF BitmapImage from a System.Drawing.Bitmap 转换为 BitmapImage

但是当我的位图发生变化时,我想要图像的来源,即BitmapImage会随着位图实时变化,我该怎么做呢?

我生成位图的代码是这样的:

Rectangle rect = new Rectangle(0, 0, 300, 300);
bitmap = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bitmap);
DoWithGraphics(g, rect, pictureelements);

DoWithGraphics 是一系列 g.FillRectangle
谢谢!

【问题讨论】:

  • Sooo.. 您想实时查看添加到图像中的每个矩形吗?
  • DoWithGraphics 将填充矩形,我想实时查看矩形。该项目最初是在 WinForm 中实现的,我正在尝试将其更改为 WPF。

标签: wpf bitmap real-time bitmapimage


【解决方案1】:

Image 控件中显示位图并在位图更改时更新Source 属性应该不是问题。

【讨论】:

    猜你喜欢
    • 2014-12-03
    • 1970-01-01
    • 2012-06-15
    • 2012-08-06
    • 1970-01-01
    • 2016-03-25
    相关资源
    最近更新 更多