VB.NET屏幕截图

时间:2014-01-21 16:00:33

标签: vb.net screen-capture

大家好我正在使用以下代码捕获visual basic 2005中窗口黑色面板的截图。

我的问题是我希望红色边框图像介于两者之间并且是满的。

enter image description here

我的代码:

    Dim bounds As Rectangle  
    Dim screenshot As System.Drawing.Bitmap  
    Dim graph As Graphics  
    bounds = Screen.PrimaryScreen.Bounds  
    screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb)  
    graph = Graphics.FromImage(screenshot)  
    graph.CopyFromScreen(618, 191, 850, 455, bounds.Size, CopyPixelOperation.SourceCopy)  
    screenshot.Save("d:\\dcap.bmp", Imaging.ImageFormat.Bmp)  `

enter image description here

1 个答案:

答案 0 :(得分:2)

您的代码可以很好地将边界设置为零

 Dim bounds As Rectangle
    Dim screenshot As System.Drawing.Bitmap
    Dim graph As Graphics
    bounds = Screen.PrimaryScreen.Bounds
    screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppRgb)
    graph = Graphics.FromImage(screenshot)
    graph.CopyFromScreen(0, 0, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
    screenshot.Save("d:\\dcap.jpg", Imaging.ImageFormat.Bmp)