Accessing DirectDraw surface memory directly in C#

1k views Asked by At

I have a video capture card that works by periodically filling a user-specified buffer (a given memory address) with image data. That works for me in C++, because I can just give it a Surface.lpSurface pointer address and the capture card driver will automatically fill it with new image data every frame, upon which I can flip() and get the new image, resulting in a nice clean video feed.

The problem is that I'm porting to C# and I need to be able to do the same thing, but the Managed version of DirectDraw.Surface has no method/property for obtaining the memory address of the surface memory area. All I need is this address, is there no way to get it using C#?

1

There are 1 answers

0
groundh0g On

If you're referring to MDX, it's been a while since I've played with it, so this may be total nonsense, but there should be a "Lock" method on the Surface that would give access to the bytes, but it might be a bit slower than you're used to with direct access to the underlying pointer ...

You may be able to mark your project / class as "unsafe", then access the native DX routines to get the pointer via pinvoke? Then, the unsafe part of your code should be able to access the data directly. Right?

Sorry if this reply is useless nonsense. Like I said, it's been a while since I played with DirectShow / MDX. Maybe this will provide some google fodder, or spark some ideas on your side.