title: Taking a screenshot using Graphics.CopyFromScreen with 150% scaling
body: <p>I'm trying to create a screenshot/bitmap of my screen. I wrote this function:</p>
  
  <pre><code>public static Bitmap CreateScreenshot(Rectangle bounds)
  {
      var bmpScreenshot = new Bitmap(bounds.Width, bounds.Height, 
                                     PixelFormat.Format32bppArgb);
      var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
      gfxScreenshot.CopyFromScreen(bounds.X, bounds.Y,
          0, 0,
          new Size(bounds.Size.Width, bounds.Size.Height),
          CopyPixelOperation.SourceCopy);
      return bmpScreenshot;
  }
  </code></pre>
  
  <p>This function is being called in my overlay form that should draw the bitmap onto itself. I'm currently using GDI+ for the whole process.</p>
  
  <pre><code>private void ScreenshotOverlay_Load(object sender, EventArgs e)
  {
      foreach (Screen screen in Screen.AllScreens)
          Size += screen.Bounds.Size;
      Location = Screen.PrimaryScreen.Bounds.Location;
  
      _screenshot = BitmapHelper.CreateScreenshot(new Rectangle(new Point(0, 0), Size));
      Invalidate(); // The screenshot/bitmap is drawn here
  }
  </code></pre>
  
  <p>Yep, I dispose the bitmap later, so don't worry. ;)
  On my laptop and desktop computer this works fine. I've tested this with different resolutions and the calculations are correct. I can see an image of the screen on the form.</p>
  
  <p>The problem starts with the Surface 3. All elements are being scaled by a factor of 1.5 (150%). This consequently means that the DPI changes. If I try to take a screenshot there, it does only capture like the upper-left part of the screen but not the whole one.
  I've made my way through Google and StackOverflow and tried out different things:</p>
  
  <ol>
  <li>Get the DPI, divide it by 96 and multiply the size components (X and Y) of the screen with this factor.</li>
  <li>Add an entry to <em>application.manifest</em> to make the application DPI-aware.</li>
  </ol>
  
  <p>The first way did not bring the desired result. The second one did, but the whole application would have to be adjusted then and this is quite complicated in Windows Forms.</p>
  
  <p>Now my question would be: Is there any way to capture a screenshot of the whole screen, even if it is has a scalation factor higher than 1 (higher DPI)?
  There must be a way to do this in order to make it working everywhere.</p>
  
  <p>But at this point I had no real search results that could help me.
  Thanks in advance.</p>