WPF-DirectX 互操作问题 (D3DImage)
我正在使用 D3DImage 编写视频应用程序。帧来自内存,并使用 DirectX9 在本机代码中渲染为纹理,最终由 D3DImage 暴露给 WPF GUI。我在上面有一些叠加层,是使用 WPF 的绘画框架(文本、形状等)创建的。到目前为止,它就像一个魅力。 现在,我想从底层本机 C++ 代码对合成图像进行编码。视频为 640x480 BGR、25 FPS,必须并行渲染和编码,在 Windows 版本低至 XP/SP3 的旧硬件上也是如此。
问题是,我找不到任何描述 WPF 和 D3DImage 之间的合成过程的文档。它们在某种意义上是“混合”的,但这是什么意思呢?是否有可能在我的本机 C++ 代码中获取绘图的 WPF 部分甚至合成图像的句柄?
ps:我也对托管解决方案持开放态度,但到目前为止还没有发现太多性能。
I'm writing a Video application utilizing D3DImage. Frames are from memory and rendered as textures in native code with DirectX9, finally exposed by D3DImage to the WPF GUI. I have some Overlays on top, created with WPF's painting framework (Text, shapes etc.). Up to this point, it works like a charm.
Now, I would like encode the composited image from my underlying native C++ code. Video is 640x480 BGR, 25 FPS and has to be rendered and encoded in parallel, also on older Hardware with Windows versions down to XP/SP3.
Problem is, I cannot find any documentation describing the composition process between WPF and D3DImage. They 'blend' in some sense, but what is the meaning of this? And is it possible to get a handle to the WPF's part of the drawing or even the composited image in my native C++ code?
p.s: I'm also open to managed solutions, but didn't found much performant up to now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个名为“CompositionTarget.Rendering”的全局静态方法。向其中添加一个事件,每次 WPF 呈现时,都会在 WPF 呈现之前调用该方法(尽管 FPS 可能会有所不同)。因此,只需相应地更新您的 renderTarget 即可。
可能有更好的方法,但我不知道。
注意::同样,对于 WindowsXP 上的 D3DImage,您使用具有可锁定渲染目标的 D3D9 设备,而在 Vista/7 上,您使用具有不可锁定渲染目标的 D3D9Ex 设备。只是一个注释。
There is global static method called "CompositionTarget.Rendering". Add an event to that and every time WPF renders that method will be called before WPF presents(the FPS can vary though). So just updated your renderTarget accordingly.
There might be a better way, but i'm not aware of it.
NOTE:: Also for D3DImage on WindowsXP you use a D3D9 device with a lockable renderTarget while on Vista/7 you use a D3D9Ex device with a non-lockable renderTarget. Just a note.