views:

181

answers:

2

I am working on an application and I have a problem I just cant seem to find a solution for. The application is written in vc++. What I need to do is display a YUV video feed with text on top of it.

Right now it works correctly by drawing the text in the OnPaint method using GDI and the video on a DirectDraw overlay. I need to get rid of the overlay because it causes to many problems. It wont work on some video cards, vista, 7, etc.

I cant figure out a way to complete the same thing in a more compatible way. I can draw the video using DirectDraw with a back buffer and copy it to the primary buffer just fine. The issue here is that the text being drawn in GDI flashes because of the amount of times the video is refreshed. I would really like to keep the code to draw the text intact if possible since it works well.

Is there a way to draw the text directly to a DirectDraw buffer or memory buffer or something and then blt it to the back buffer? Should I be looking at another method all together? The two important OS's are XP and 7. If anyone has any ideas just let me know and I will test them out. Thanks.

+2  A: 

Try to look into DirectShow and the Ticker sample on microsoft.com:

DirectShow Ticker sample

This sample uses the Video Mixing Renderer to blend video and text. It uses the IVMRMixerBitmap9 interface to blend text onto the bottom portion of the video window.

DirectShow is for building filter graphs for playing back audio or video streams an adding different filters for different effects and manipulation of video and audio samples.

gyurisc
+1  A: 

Instead of using the Video Mixing Renderer of DirectShow, you can also use the ISampleGrabber interface. The advantage is, that it is a filter which can be used with other renderers as well, for example when not showing the video on the screen but streaming it over network or dumping it to a file.

Rupert Jones
The disadvantage of this, though, is that you are doing the mixing yourself in software, and disabling hardware assisted decoding or deinterlacing. If you use the vmr mixer bitmap api, you can use hardware-assisted alpha blending.
Geraint Davies
+1 for ISampleGrabber, since I use it extensively to paint to real-time video in .NET with GDI+. even on YUY2 surfaces :)
Daniel Mošmondor