为了账号安全,请及时绑定邮箱和手机立即绑定

C# 将视图模型的属性传递给调度程序

C# 将视图模型的属性传递给调度程序

PHP
温温酱 2021-06-30 18:55:56
我有一个方法可以更新 WriteableBitmap (FrameDataNew) 的内容,它是我的视图模型 (VM) 中的一个属性:    public WriteableBitmap FrameDataNew    {        get { return frameDataNew; }        set        {            frameDataNew = value;            OnProptertyChanged("FrameDataNew");        }    }    private WriteableBitmap frameDataNew = null; 当我从我编写的 gstreamer 类收到一个新的位图时,我更新 FrameDataNew 以便在屏幕上显示最新的帧。该窗口是一个简单的 Image 控件,其源绑定到 FrameDataNew。以下代码可以很好地在我的事件处理程序中执行此操作:    /// <summary>    /// BitmapCaptured event handler for when a new video frame is received from the IP source    /// </summary>    /// <param name="sender">The originating source of the event</param>    /// <param name="NewBitmap">The new frame in Bitmap form</param>    private void PipeLine_BitmapCaptured(object sender, Bitmap NewBitmap)    {        // render to the screen        Dispatcher.Invoke(() =>        {            // check the existence of the WriteableBitmap and also the dimensions, create a new one if required            if ((VM.FrameDataNew == null) || (VM.FrameDataNew.Width != NewBitmap.Width) || (VM.FrameDataNew.Height != NewBitmap.Height))                VM.FrameDataNew = new WriteableBitmap(NewBitmap.Width, NewBitmap.Height, NewBitmap.HorizontalResolution, NewBitmap.VerticalResolution, PixelFormats.Bgr24, null);            // lock the bitmap data so we can use it            BitmapData data = NewBitmap.LockBits(new Rectangle(0, 0, NewBitmap.Width, NewBitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);现在我想更新我的程序以处理多个管道和 WriteableBitmaps,以便我可以显示多个视频源。我做的第一件事是创建一个静态实用程序类,以便我可以传入我希望更新的新位图 (NewBitmap) 和 WriteableBitmap (VM.FrameDataNew)。图像不再出现在屏幕上。单步执行代码,每次调用 InjectBitmap() 时,目标 WriteableBitmap 是否为空?代码在第一个 if 语句中创建了一个新的,但 VM.FrameDataNew 保持为空?我绝对处于我在这方面经验的边缘,因此非常感谢任何帮助。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 146 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信