WPF-DirectX Interop Task (D3DImage)

I am writing a video application using D3DImage. The frames are from memory and are displayed as textures in native code with DirectX9, which are finally displayed by D3DImage in the WPF GUI. I have some Overlays on top created using a WPF drawing frame (text, shapes, etc.). Until this moment, it works like a charm. Now I would like to encode a composite image from my main C ++ code. The video is 640x480 BGR, 25 FPS and must be presented and encoded in parallel, also on old hardware with Windows versions up to XP / SP3.

The problem is that I cannot find the documentation describing the linking process between WPF and D3DImage. They "mix" in a way, but what's the point of this? And is it possible to get a handle to the WPF part of a drawing or even a composite image in my native C ++ code?

ps: I am also open to managed solutions, but so far have not worked very much.

+4
source share
1 answer

There is a global static method called "CompositionTarget.Rendering". Add an event to this and every time WPF displays this method, which will be called before the WPF submission (FPS may change). So just update your renderTarget accordingly. Maybe the best way, but I don't know about that.

NOTE. Also for D3DImage on WindowsXP, you use a D3D9 device with lockable rendering, while in Vista / 7 you use a D3D9Ex device with unlockable rendering. Just a note.

+2
source

Source: https://habr.com/ru/post/1337605/


All Articles