I am using VB.NET to try and capture a portion of the screen so I found this code in several places to capture the whole screen:
Dim screenSize = SystemInformation.PrimaryMonitorSize
Dim bitmap = New Bitmap(screenSize.Width, screenSize.Height)
Using g As Graphics = Graphics.FromImage(bitmap)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)
End Using
bitmap.Save("c:\scratch\screenshot.png", System.Drawing.Imaging.ImageFormat.Png)
This works with no error throw and the file is created successfully but the resulting image is completely transparent (it is the correct size) – what am I missing?
This question relates to the same error but the solution is to use Win32 GDI which I want to avoid if possible
I decided to go along the print screen option in the end due to the issues with the CopyFromScreen method: