VB.NET Screen Capture

妖精的绣舞 提交于 2019-12-11 08:19:15

问题


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

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

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)  `


回答1:


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)


来源:https://stackoverflow.com/questions/21263096/vb-net-screen-capture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!