簡體   English   中英

VB.NET屏幕截圖

[英]VB.NET Screen Capture

您好,我正在使用下面的代碼來捕獲Visual Basic 2005中窗口窗體黑色面板的屏幕截圖。

我的問題是我希望紅色邊框圖像介於兩者之間並充滿。

在此處輸入圖片說明

我的代碼:

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

在此處輸入圖片說明

您的代碼運行良好,只需將邊界設置為零

 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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM