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.
Thanks.
http://www.gamedev.net/community/forums/topic.asp?topic_id=537265&whichpage=1�
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);
Then resolve the back buffer in your Draw method after you draw your scene:
graphics.GraphicsDevice.ResolveBackBuffer(renderTargetTexture);
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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With