views:

60

answers:

1

what i want to do is write an application in C# like "fraps" and other scren capture apps that when you press the "Print Screen" it saves the current screen as an image.

What i thought of is that

"i could create a background worker thread that checks the clipboard after x seconds and if there is an image, that is now in clipboard because of print screen click, it writes the clipboard contents to a jpeg or bitmap file" bu i lack the following knowledge

  • How will i know that there is an image in clipboard or some text or file

  • how to write that clipboard to an image file like how to convert that data into a JPEG (LZ-W format) or bitmap format etc.

Can anybody endow me with some knowledge or guide or help from C# coding prespective

+2  A: 

The saving to a particular format is incredibly easy thanks to the Image class:

myImage.Save("someimage.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

As far as checking the clipboard, well you can do this, but i think you might run into issues that you won't know whether the image came from a Print-Screen, or from a Ctrl-c that the user did. However you can easily check the clipboard:

if (Clipboard.ContainsImage())  
    myImage = Clipboard.GetImage();
DeusAduro