Speed Up Suggestions

Jan 27, 2010 at 4:44 PM

First use the newer directshow lib. This does cause some code changes but they are worth it.

To speed this thing up I suggest changing the capture type to ARGB32

mt.subType = MEDIASUBTYPE_RGB24;    // RGB24  -> mt.subType = MediaSubType.MEDIASUBTYPE_ARGB32

This will give you the data in a format that doesnt need to be converted, but it is upside down so when drawing use SpriteEffects.FlipVertically.

That gets rid of the whole converting loop which is a big slow down.

Also, instead of using BufferCB use SampleCB because using BufferCB incurs an extra copy (according to MSDN docs)

Instead use

IntPtr ptr;

pSample.GetPointer(out ptr)

then copy the (ARGB) data from that pointer using Marshal.Copy