DirectDraw surface memory access directly in C #

I have a video capture card that works by periodically populating a user-specified buffer (given memory address) with image data. This works for me in C ++, because I can just give it the address of the Surface.lpSurface pointer, and the capture card driver will automatically fill it with new image data in each frame, after which I can flip () and get a new image, as a result bringing a nice clean video feed.

The problem is that I am porting to C # and I need to be able to do the same, but the managed version of DirectDraw.Surface does not have a method / property to get the memory address of the surface memory area. All I need is an address, is there no way to get it using C #?

+3
source share
1 answer

If you mean MDX, it’s been a while since I played with it, so it can be completely stupid, but there should be a β€œLock” method on the surface that will give access to bytes, but it can be a little slower than you are used to with direct access to the main pointer ...

Perhaps you can mark your project / class as "unsafe", then access the built-in DX procedures to get the pointer through pinvoke? Then, the insecure part of your code should be able to access data directly. Correctly?

, . , , DirectShow/MDX. , Google, .

+1

Source: https://habr.com/ru/post/1791307/


All Articles