问题
I am trying to draw something on a live video. The best way to do that in my opinion is to handle the WM_PIANT event.
My purpose is to make the player draw first and after that the application. That way I will be able to draw on the video. It means that I want to be notified each time before we need to paint a new frame on the window and then handle the event.
I use DirectshowNet so I am programming in C# (I have all the interfaces the c++'s API has). I understand that the graph manager forward certain window messages to the Video Renderer such as the WM_PAINT.
How can I cause the player to draw a frame before the application and not after?
回答1:
WM_PAINT
is not the best way, moreover it is the wrong way.
Check out DxText
sample from DirectShow.NET library. Its description is:
A sample application showing how to superimpose text strings on a datastream. The stream is read from an avi file.
This is so close to what you are trying to reach. An alternate approach is shown in another sample there, BitmapMixer
:
BitmapMixer is an example of how to draw things over a video using VMR9.
This sample is mainly built around the IVMRMixerBitmap9 interface. This interface accept bitmaps as a GDI Device Context or as a Direct3D Surface. The main advantage of the Direct3D Surface is that it enables the use of true alpha transparency. GDI DC don't support alpha bitmap and transparency is accomplished by using color keying.
This sample dynamically generates bitmaps using GDI+.
来源:https://stackoverflow.com/questions/12671696/how-to-control-the-painting-of-the-player