|
[em7]
我想把 屏幕截取出来,然后用directx 渲染一下。
代码大致如下
surface = scrDevice.CreateOffscreenPlainSurface(scrDevice.DisplayMode.Width ,scrDevice.DisplayMode.Height , Format.A8R8G8B8, Pool.SystemMemory );
scrDevice.GetFrontBufferData(0, surface);
GraphicsStream gStream = SurfaceLoader.SaveToStream(ImageFileFormat.Jpg, surface, new Rectangle(0, 0, 1024, 768));
gStream.Seek(0, System.IO.SeekOrigin.End);
texture = TextureLoader.FromStream(device, gStream);
(c#代码,不会c++, 大概思路就是
通过 CreateOffscreenPlainSurface(),GetFrontBufferData()把桌面放到 surface里,然后把surface转换成stream,再把stream转换成texture) 这样的问题 是 surface,转换成stream,在转换成texture,消耗的时间太长。有没有其他什么办法啊?
查了资料,貌似 surface ->GetContainer()可以得到texture,但貌似surface如果是通过GetFrontBufferData()方法生成的,没办法得到他的texture, 有没有其他什么办法,可以把桌面截取出来 然后放到texture里渲染啊?
知道你们都是用c++的,说说c++里怎么做也可以啊。谢谢了。 |
|