1

i was trying to get screenshot for the whole screen, but when i try to use Screen.PrimaryScreen it gets the screen right, but not the full screen. The strange part when i try to save the image i get, it's equal the resolution as my PC's resolution is. Here is the code :

            var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                                   Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);

            //Create a graphics object from the bitmap.
            var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

            //Take the screenshot from the upper left corner to the right bottom corner.
            gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                                        Screen.PrimaryScreen.Bounds.Y,
                                        0,
                                        0,
                                        Screen.PrimaryScreen.Bounds.Size,
                                        CopyPixelOperation.SourceCopy);

            bmpScreenshot.Save("New.png", ImageFormat.Png);

As you can see it should work, but i got no idea why it doesn't get the complete Full Screen, Here is a picture : Problem's Picture

Thanks.

GameHackerPM
  • 97
  • 1
  • 10
  • I tested your code, seems to work just fine here. – Jim Nov 01 '16 at 00:03
  • 1
    What do you expect could be from then? Also you tested it on which version of VS or NetFramework? @Jim – GameHackerPM Nov 01 '16 at 00:04
  • The version of VS should not matter, the target framework (maybe) if you are targeting an old one, you should mention it. *(I have tested this in 4.5.2)* – Jim Nov 01 '16 at 00:09
  • Nope, didn't use any old, also now i tried 4.0 , 4.5.2 , 4.6.1 , 3.5. No changes! – GameHackerPM Nov 01 '16 at 00:14
  • Look at this [Picture](http://image.prntscr.com/image/0bdb79854a9146a8b672da47fe77116b.png) @Jim – GameHackerPM Nov 01 '16 at 00:23
  • 1
    Your best shot is to investigate why `Screen.PrimaryScreen.Bounds.` doesn't give the correct information ... this can be due DPI scaling. I have found a topic that might be interesting to start for you http://stackoverflow.com/questions/27987085/screen-resolution-not-matching-screen-bounds – Jim Nov 01 '16 at 00:32
  • 1
    Great, followed it and got it fixed! Thank you! (Although i though that after VS 2012, that done automated) – GameHackerPM Nov 01 '16 at 00:55
  • @GameHackerPM post your new findings as an answer and accept it. – Lex Li Nov 01 '16 at 02:00

0 Answers0