VB.NET 屏幕截图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21263096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 17:24:14  来源:igfitidea点击:

VB.NET Screen Capture

vb.netscreen-capture

提问by GTARaja

Hello all i am using the below code to capture the screenshot of the black panel of my window form in visual basic 2005.

大家好,我正在使用以下代码在 Visual Basic 2005 中捕获我的窗口窗体的黑色面板的屏幕截图。

My problem is that I want the red border image to come in between and to be full.

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

enter image description here

在此处输入图片说明

My code :

我的代码:

    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

在此处输入图片说明

回答by user3664693

Your code works well just set the bounds to zero

您的代码运行良好,只需将边界设置为零

 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)