private void Initialize(IMemoryRendererEx renderer) { m_source = renderer; m_source.SetFormatSetupCallback(OnFormatSetup); m_source.SetCallback(OnNewFrame); this.d3dSource = new D3DImageSource(); }
private void Refresh() { if (_backBufferPointer == IntPtr.Zero) { return; } D3DImageSource.Lock(); // Calling SetBackBuffer repeatedly with the same IntPtr is a no-op, so there's no // performance penalty. D3DImageSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _backBufferPointer, true); ModelEditorViewModel vm = (ModelEditorViewModel)DataContext; _renderer.Render(vm.RenderParameters); D3DImageSource.AddDirtyRect(new Int32Rect(0, 0, (int)ActualWidth, (int)ActualHeight)); D3DImageSource.Unlock(); }
private void Refresh() { if (_backBufferPointer == IntPtr.Zero) { return; } D3DImageSource.Lock(); // Calling SetBackBuffer repeatedly with the same IntPtr is a no-op, so there's no // performance penalty. D3DImageSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, _backBufferPointer); if (D3DImageSource.IsFrontBufferAvailable) { Render(); } D3DImageSource.AddDirtyRect(new Int32Rect(0, 0, (int)ActualWidth, (int)ActualHeight)); D3DImageSource.Unlock(); }
public MainWindow() { InitializeComponent(); this.timer = new Timer(); this.timer.Interval = 40; this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); this.d3dSource = new D3DImageSource(); this.wbSource = new WriteableBitmapSource(); this.frameIndex = 0; try { this.yuvData = FrameData.LoadData("yv12.dat"); if (this.wbSource.SetupSurface(this.yuvData.FrameWidth, this.yuvData.FrameHeight, FrameFormat.YV12)) { this.imageWB.Source = this.wbSource.ImageSource; } else { MessageBox.Show("WriteableBitmapSource不支持该种帧格式:" + FrameFormat.YV12); } if (this.d3dSource.SetupSurface(this.yuvData.FrameWidth, this.yuvData.FrameHeight, FrameFormat.YV12)) { this.imageD3D.Source = this.d3dSource.ImageSource; } else { MessageBox.Show("本机显卡不支持该种帧格式:" + FrameFormat.YV12); } } catch { MessageBox.Show("加载数据文件失败"); } }
private void SwitchPreviewWindowSceneHandler(PreviewWindowInfo previewWindowInfo) { AllSceneHidden(); _player.Pause(); if (_d3dSource == null) { try { _d3dSource = new D3DImageSource(); if (_d3dSource.SetupSurface(1280, 720, FrameFormat.YV12)) { this.imageD3D.Source = this._d3dSource.ImageSource; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } _desktopWindowCollector.SetWindowHandle(previewWindowInfo.HWD); _desktopWindowCollector.PushingData += _desktopWindowCollector_PushingData; LiveWindowPreviewScene.Visibility = Visibility.Visible; }