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里渲染啊?
(大家看看我的结贴率,就该我是不平凡的人,分数多多啊。。)
代码大致如下
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里渲染啊?
(大家看看我的结贴率,就该我是不平凡的人,分数多多啊。。)
...全文
相关推荐
An intelligent software platform for machining surface texture
An intelligent software platform for machining surface texture
从SDL_Surface到SDL_Texture:SDL2渲染流程的深度解析
本文深度解析SDL2渲染流程,重点阐述SDL_Surface、SDL_Texture与SDL_Renderer三大核心组件的角色与协作关系。SDL_Surface是CPU端的像素数据存储,适合图像处理;SDL_Texture是GPU端的加速纹理,用于高效渲染;SDL_Renderer则负责调度与绘制。掌握从Surface到Texture的转换及渲染循环,是优化性能、避免卡顿的关键。
Render to Texture(渲染到纹理)
·内容 渲染到纹理是D3D中的一项高级技术。一方面,它很简单,另一方面它很强大并能产生很多特殊效果。 比如说发光效果,环境映射,阴影映射,都可以通过它来实现。渲染到纹理只是渲染到表面的一个延伸。我们只需再加些东西就可以了。首先,我们要创造一个纹理,并且做好一些防范措施。第二步我们就可以把适当的场景渲染到我们创建的纹理上了。然后,我们把这个纹理用在最后的渲染上。·main.cpp 首先我们得声明
opengl教程
onSurfaceCreated、onDrawFrame、onSurfaceChanged
不良气象微环境对机场道面抗滑性能影响分析.docx
不良气象微环境对机场道面抗滑性能影响分析.docx


