屏幕截图问题 [英] Screen Shot problem

查看:68
本文介绍了屏幕截图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我制作了一个屏幕截图程序,但有一个问题,它没有占据整个屏幕



见 - > http://prntscr.com/9i2fpd



我使用这些代码



Hi

I am made a screen shot program but there is a problem, it is not taking the whole screen

see --> http://prntscr.com/9i2fpd

I used these codes

Public Class Form1

    Function ScreenToPicture(ByVal Location As String) As String

        Try
            Dim currentScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim ScreenToBitmap As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
            Dim gGraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(ScreenToBitmap)

            gGraphics.CopyFromScreen(New Point(0, 0), New Point(0, 0), currentScreenSize)
            ScreenToBitmap.Save(Location)

            Return Location

        Catch ex As Exception
            Return ex.Message
        End Try

    End Function

    Private Property Path As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim b As Bitmap = New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height, Imaging.PixelFormat.Format32bppArgb)
        Dim gfx As Graphics = Graphics.FromImage(b)
        gfx.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)

        Path = "C:\Users\" + Environment.UserName + "\Desktop\" + Label1.Text + ".jpg"
        b.Save(Path, Imaging.ImageFormat.Jpeg)

        Label1.Text = Label1.Text + 1
    End Sub
End Class

推荐答案

检查 My.Computer.Screen.Bounds 返回的结构中的值。它们应与主屏幕分辨率的尺寸相匹配。如果它们不匹配,请阅读此主题 [ ^ ]。这通常是因为主监视器上的DPI设置未设置为100%且您的代码不是DPI Aware。
Check the values in the structure returned by My.Computer.Screen.Bounds. They should match the dimensions of your primary screen resolution. If they don't match, read this thread[^]. It's usually because the DPI setting on your primary monitor isn't set to 100% and your code isn't "DPI Aware".


这篇关于屏幕截图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆