Search code examples
c#videotransparencydirectshowdirectshow.net

Showing a semi-transparent Image object over an IVideoWindow in C# using DirectShow.NET


I've been using DirectShow.NET to interface with a webcam in C# and so far everything has been going smoothly. However, right now I'm working on trying to set up a method to "crop" an image (while it's still being displayed as a webcam preview).

Basically, I'm trying to show some kind of a mostly transparent image on top of the IVideoWindow object. Dealing with transparency in C#, however, has been pretty far from a cakewalk.

So, how can I layer an Image object on top of an IVideoWindow? Thanks!


Solution

  • There are two approaches how to achieve this:

    • to use a video transformation filter and deliver mixed video to the renderer (that is, picture + your overlay)
    • or, use VMR's 'mixerbitmap` feature to overlay at presentation time

    DirectShow.NET has a sample for the second mentioned above:

    Samples\VMR9\BitMapMixer BitmapMixer is an example of how to draw things over a video using VMR9.

    Another sample there:

    Samples\Players\DxText A sample application showing how to superimpose text strings on a datastream. The stream is read from an avi file.

    Also discussed many times on MSDN Forums.