surface to texture
我想把 屏幕截取出来,然后用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#代码, 大概思路就是
通过 CreateOffscreenPlainSurface(),GetFrontBufferData()把桌面放到 surface里,然后把surface转换成stream,再把stream转换成texture) 这样的问题 是 surface,转换[来源:GameRes.com]成stream,在转换成texture,消耗的时间太长。有没有其他什么办法啊?
查了资料,貌似 surface ->GetContainer()可以得到texture,但貌似surface如果是通过GetFrontBufferData()方法生成的,没办法得到他的texture, 有没有其他什么办法,可以把桌面截取出来 然后放到texture里渲染啊?
(大家看看我的结贴率,就该我是不平凡的人,分数多多啊。。)