2006-02-18

Screen capture tool

I've written a little screen capture tool, for fun. You can download it from Box. I did not include the source code, because there isn't a lot of it. Just use Reflector for that. Here's the bit of code that does the actual capturing and copying to the clipboard:
Rectangle region = ...; // the screen region to capture
using (Bitmap bitmap =
    new Bitmap(region.Width, region.Height, PixelFormat.Format32bppArgb))
using (Graphics bitmapGraphics = Graphics.FromImage(bitmap))
{
    bitmapGraphics.CopyFromScreen(region.Left, region.Top, 0, 0, region.Size);
    Clipboard.SetImage(bitmap);
}
EDIT: I've updated the tool: after capturing, you can now directly save the screenshot too.