surface to texture

cccccui cccccui 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想把 屏幕截取出来,然后用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里渲染啊?



(大家看看我的结贴率,就该我是不平凡的人,分数多多啊。。)

...全文
评论 10
收藏 已收藏
分享
返回顶部
cccccui
游戏开发 8,324 成员 23,685 内容