在XNA中拍摄屏幕截图
如何在XNA中截取屏幕截图? 没有System.Drawing.Graphics.CopyFromScreen
或Win32API可以吗? 如果不可能,有没有办法将System.Drawing.Bitmap
绘制到游戏中?
我希望它会采用屏幕截图,然后以全屏模式加载游戏,然后打印屏幕截图。
谢谢。
http://www.gamedev.net/community/forums/topic.asp?topic_id=537265&whichpage=1�
首先在游戏的LoadContent方法中创建一个ResolveTexture2D:
renderTargetTexture = new ResolveTexture2D( graphics.GraphicsDevice, graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, graphics.GraphicsDevice.PresentationParameters.BackBufferFormat);
绘制场景后,在Draw方法中解析后缓冲区:
graphics.GraphicsDevice.ResolveBackBuffer(renderTargetTexture);
最后,当您的Draw方法暂停游戏时,使用spritebatch绘制捕获的后台缓冲区:
spriteBatch.Draw(renderTargetTexture, Vector2.Zero, Color.White);
如果您希望图像为灰度,则需要编写像素着色器并在LoadContent中使用效果文件加载它,然后在使用spritebatch绘制纹理之前设置效果。