采取XNA屏幕截图 [英] Take screen shot in XNA
问题描述
我怎么可以在XNA画面的截图?是否有可能不 System.Drawing.Graphics.CopyFromScreen
或Win32API的?如果这是不可能的,有没有什么办法来画一个 System.Drawing.Bitmap
游戏
How can I take a screen shot of the screen in XNA? Is it possible without System.Drawing.Graphics.CopyFromScreen
or Win32API? If it's not possible, Is there any way to draw a System.Drawing.Bitmap
to the game?
我希望它会采取一个屏幕截图,然后加载在全屏模式下游戏,然后打印的屏幕截图。
I want that it'll take a screen screenshot, then load the game in full screen mode, and then print the screenshot.
感谢。
推荐答案
的 http://www.gamedev.net/community/forums/topic.asp?topic%5Fid=537265&whichpage=1�
在您游戏的LoadContent方法首先创建一个ResolveTexture2D:
First create a ResolveTexture2D in your game's LoadContent method:
renderTargetTexture = new ResolveTexture2D(
graphics.GraphicsDevice,
graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1,
graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);
然后解决您的Draw方法后缓冲区您绘制场景后:
Then resolve the back buffer in your Draw method after you draw your scene:
graphics.GraphicsDevice.ResolveBackBuffer(renderTargetTexture);
最后,使用spritebatch绘制抓获后缓冲区,当你的游戏暂停在你的绘制方法:
Finally, draw your captured back buffer using a spritebatch when your game is paused in your Draw method:
spriteBatch.Draw(renderTargetTexture, Vector2.Zero, Color.White);
如果您希望图像灰度是,你需要写一个像素着色器并加载它与您LoadContent效果文件,然后与spritebatch绘制纹理之前设置的效果。
If you want the image to be grayscale, you'll need to write a pixel shader and load it with an effect file in your LoadContent, then set the effect before drawing the texture with the spritebatch.
这篇关于采取XNA屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!