Can so开发者_C百科meone help me, how can I printscreen my screen that can be saved in gif or jpeg format locally in VB.net
I know this question was asked a long time ago so I post this for posterity.
It's quite trivial to preform a screen capture operation using the CopyFromScreen method in the Graphics class. Also, the BitMap class ships with a Save method; making this even more trivial.
Using image As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
Using surface As Graphics = Graphics.FromImage(image)
surface.CopyFromScreen(Screen.PrimaryScreen.Bounds.Location, Point.Empty, image.Size)
End Using
image.Save("C:\myimage.jpg", Imaging.ImageFormat.Jpeg)
End Using
One possible solution when dealing with multiple monitors is to iterate, capture and save each screen as individual images. Place the above code inside the following For Each Next statement and replace Screen.PrimaryScreen with monitor. Be sure that you set a unique file name for each image.
For Each monitor As Screen In Screen.AllScreens
'...
Next
精彩评论