문제

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.

도움이 되었습니까?

해결책

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`
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top