[.net] Screenshot of desktop

Started by
8 comments, last by DrGUI 19 years, 4 months ago
I want to make a desktop-destroyer type screensaver w DX, but how do I get a screenshot to use as a texture?
Advertisement
This will do the trick:

using Microsoft.DirectX.Direct3D;// ...Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);backbuffer.Dispose();


Now you can do whatever you like with the bitmap.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Or, perhaps easier:
1. While viewing your desktop, press print screen
2. Open paint, set the attributes of the picture to reflect the size of your desktop
3. Go to edit and choose paste
4. Save the picture
Quote:Original post by tool_2046
Or, perhaps easier:
1. While viewing your desktop, press print screen
2. Open paint, set the attributes of the picture to reflect the size of your desktop
3. Go to edit and choose paste
4. Save the picture


He means a current screen capture whenever the screen saver is activated.
Quote:Original post by kSquared
This will do the trick:

*** Source Snippet Removed ***

Now you can do whatever you like with the bitmap.

I forget to mention, the code above is in C#, if you couldn't tell. You didn't mention what language you were using, but converting it into MC++ or VB.Net should be no problem if that's what you're using.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
kSquared, I don't think he wants to actually save a bitmap, just use the desktop as a texture..

You could try making the form completely transparent, not sure if that works with full screen apps.. then just blit some things on top I guess.
Well, kSquared's code will still work, have to change the SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer); line to save it to a texture in stead. Which is no biggy.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Quote:Original post by ontheheap
Quote:Original post by tool_2046
Or, perhaps easier:
1. While viewing your desktop, press print screen
2. Open paint, set the attributes of the picture to reflect the size of your desktop
3. Go to edit and choose paste
4. Save the picture


He means a current screen capture whenever the screen saver is activated.

That's right, thanks. Perhaps I should have explained a little better.
I want a screenshot of the desktop just before the screensaver starts, not of my rendering with DX.

Thanx for your help.
http://www.c-sharpcorner.com/Code/2003/Dec/ScreenCapture.asp
is an example I found that uses pinvoke on GDI32 nad User32.
That looks very useful, thanks.
EDIT: but still a .NET method would be preferred.

[Edited by - DrGUI on December 4, 2004 10:10:04 AM]

This topic is closed to new replies.

Advertisement