Question

For a basic personal interest project, I'm trying to make a C# winform which is a screen capture device, I want to be able to resize a transparent window, press a button on keyboard and the program save what it can see transparently through itself to a file.

All I need help with is a non-hacky way to get the image of what can be seen through the transparent window.

A quick mock up in ms paint: Mock up image

Any help would be appreciated.

Was it helpful?

Solution

Use Graphics.CopyFromScreen method:

using (Bitmap bmp = new Bitmap(width, height))
{
    using (Graphics g = Graphics.FromImage(bmp))
    {
        g.CopyFromScreen(x, y, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
    }

    // do whatever with `bmp`
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top