Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

How to take screenshot of region on screen using x1,y1,x2,y2?

$
0
0
I am trying to figure out how to take a screenshot of just a region of the screen using the x/y coordinates of the upper left corner and the x/y coordinates of the lower right hand corner?

My issue here is I don't know the image size before hand when I create the image in the function, so I am geussing it will need to somehow calculate that with the given coordinates? I have no idea any ideas would be helpful right about now. Here is the code I am using to take my screenshots.

Code:

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)  'This is where I get confused because their will be no way beforehand of knowing the imagesize.
Dim g As Graphics = Graphics.FromImage(screenGrab)
g.CopyFromScreen(New Point(0, 0), New Point(0, 0), screenSize)
Return screenGrab
End Function


Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>