Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High Quality Full Screenshots VB.Net

Tags:

vb.net

I'm trying to add a feature to my program to take a full screenshot of the users screen when they click a button. I got the program to take the screenshot and open a file dialog box to save it, the saving works. The issue is that no matter how I save the screenshot, the saved image has significant quality loss and pixelates around text and stuff. This is a massive issue because I need the image to save exactly as it is seen on the users screen, I cannot have ANY quality loss at all. I tried to save the image as a jpg and a png and both gave me quality loss. I was wondering if anyone could point me towards some code or a method that would allow me to save the screenshots at the same quality as the users screen. I would like to save the image as a JPG or a PNG if possible. Any help would greatly be appreciated!

like image 929
Tony Avatar asked Dec 16 '22 23:12

Tony


1 Answers

Get the image in Bitmap format and save it as bmp.

Private Function TakeScreenShot() As Bitmap

    Dim screenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)

    Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)

    Dim g As Graphics = Graphics.FromImage(screenGrab)

    g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)

    Return screenGrab

End Function
like image 79
Romil Kumar Jain Avatar answered Jan 07 '23 02:01

Romil Kumar Jain