如何在XNA中截取屏幕截图?是否可以在不使用System.Drawing.Graphics.CopyFromScreen
或Win32API的情况下实现?如果不可能,有没有办法将System.Drawing.Bitmap
绘制到游戏中?
我希望它可以截取屏幕截图,然后在全屏模式下加载游戏,最后打印屏幕截图。
谢谢。
如何在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);
spriteBatch.Draw(renderTargetTexture, Vector2.Zero, Color.White);