graphics screen capture makes a black image

Tanne 41 Reputation points

When I Run this code I get a black png:

class Program

    static void Main(string[] args)

        using (Bitmap screenshot = new Bitmap(53, 21))

            using (Graphics image = Graphics.FromImage(screenshot))
                image.CopyFromScreen(new Point(81, 160), new Point(134, 181), new Size(53, 21));




any ideas why?

Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
771 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 71,866 Reputation points

    new Point(134, 181) is the destination, so it is out of bounds

    replace it by new Point(0, 0)

    (and don't use Dispose when you use using...)

0 additional answers

Sort by: Most helpful