游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1535|回复: 1

surface to texture

[复制链接]

3

主题

4

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2011-5-19 23:25:00 | 显示全部楼层 |阅读模式
[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++里怎么做也可以啊。谢谢了。

3

主题

4

帖子

8

积分

新手上路

Rank: 1

积分
8
 楼主| 发表于 2011-5-20 13:23:00 | 显示全部楼层

Re:surface to texture

qiu求 回答。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-8 06:52

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表