0

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?

Matan Givoni
  • 1,080
  • 12
  • 34

1 Answers1

0

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+.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • I tried the BitmapMixer and it didn't work for me because I am using a Graphic object to draw on the player, I have a truly transparent panel over the window and I created graphics of that panel and then I used the hdc of the graphic object with the bitmapMixer thing and then I can't draw anymore on the graphics because the graphic object from now on is in use with someone else. Now I need to be able to draw something dynamically on the player, means that I will draw different thing on the player and they will stay there. Do you have any other idea? thanks for the help man. – Matan Givoni Oct 01 '12 at 16:17
  • DShow playback is never transparent. That is, you need to check out the samples on how to get frames out of there into `Graphic` objects and do not actually visualize the video. Instead you will use the individual frames and paint them the way you need outside of DShow. – Roman R. Oct 01 '12 at 16:35
  • No this isn't what i am trying to do, I am using a transparent **panel** it is a **contol** object that I made it transparent, I don't want the player to be transparent. – Matan Givoni Oct 01 '12 at 17:15