开发者

Printscreen the screen and save the image(VB)

开发者 https://www.devze.com 2023-01-13 18:59 出处:网络
Can so开发者_C百科meone help me, how can I printscreen my screen that can be saved in gif or jpeg format

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
0

精彩评论

暂无评论...
验证码 换一张
取 消