在 C# 中直接访问 DirectDraw 表面内存
我有一个视频捕获卡,它的工作原理是定期用图像数据填充用户指定的缓冲区(给定的内存地址)。这在 C++ 中对我有用,因为我可以给它一个 Surface.lpSurface 指针地址,采集卡驱动程序将自动在每一帧中用新的图像数据填充它,我可以在其中 Flip() 并获取新图像,从而产生一个漂亮干净的视频源。
问题是我正在移植到 C#,并且我需要能够执行相同的操作,但是 DirectDraw.Surface 的托管版本没有用于获取表面内存区域的内存地址的方法/属性。我只需要这个地址,有没有办法用C#获取它?
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#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您指的是 MDX,自从我使用它以来已经有一段时间了,所以这可能完全是无稽之谈,但是 Surface 上应该有一个“锁定”方法可以访问字节,但它可能比直接访问底层指针要慢一点...
您可以将您的项目/类标记为“不安全”,然后访问本机 DX 例程以通过 pinvoke 获取指针?然后,代码中不安全的部分应该能够直接访问数据。正确的?
抱歉,如果这个回复是无用的废话。正如我所说,我已经有一段时间没有使用 DirectShow / MDX 了。也许这会提供一些谷歌素材,或者激发你的一些想法。
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.