C# screenshot doesn't contain whole screen

43 Views Asked by At

I have this console app that makes a screenshot and save it, but when I open the image it doesn't capture all the screen. How can I get full 1980x1080 image of screen Screenshot that I got

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace ScreenCaptureExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Bitmap screenshot = CaptureScreen();

            screenshot.Save("D:\\ThisScreenshot.png");

            screenshot.Dispose();

            Console.WriteLine($"Screenshot has been created.");
        }

        static Bitmap CaptureScreen()
        {
            Rectangle screenSize = Screen.PrimaryScreen.Bounds;

            Bitmap screenshot = new Bitmap(screenSize.Width, screenSize.Height);

            using (Graphics gfx = Graphics.FromImage(screenshot))
            {
                gfx.CopyFromScreen(screenSize.X, screenSize.Y, 0, 0, screenSize.Size);
            }

            return screenshot;
        }
    }
}
1

There are 1 best solutions below

0
Stasich On

Yeah, it was a problem With a Windows screen size. It was scaled in 1.25x. So I multiplied Width and Height values of Screen.PrimaryScreen.Bound by 1.25.