当我玩Battlefield3时,我无法获得屏幕截图。我知道我必须捕获使用DirectX,所以我做了一些搜索并发现了这个:
Imports System.IO
Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX
Public Class form1
Public Shared Function CaptureScreenshot(ByVal Device As Direct3D.Device, ByVal Filename As String, ByVal ImageFormat As Direct3D.ImageFileFormat) As Boolean
Dim B As Direct3D.Surface
Try
B = Device.GetBackBuffer(0, 0, DirectX.Direct3D.BackBufferType.Mono)
Direct3D.SurfaceLoader.Save(Filename, ImageFormat, B)
B.Dispose()
Catch ex As Exception
Return False
End Try
Return True
End Function
Public Shared Function CaptureScreenshot(ByVal Device As Direct3D.Device, ByVal Filename As String) As Boolean
Return CaptureScreenshot(Device, Filename, Direct3D.ImageFileFormat.Bmp)
End Function
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.Load
CaptureScreenshot(Device, "capture.jpg", Direct3D.ImageFileFormat.Bmp)
End Sub
End Class
但它不起作用。它说 : 错误2“设备”是一种类型,不能用作表达式。 错误1未声明“DirectX”。由于其保护级别,它可能无法访问。
我知道游戏使用的是DirectX 11 / DirectX 10。 我是BF3中的一个部落的成员,我们希望程序以一定的时间间隔拍摄屏幕截图,计时器不是问题,我可以这样做,但我无法解决2个错误。在此先感谢,我感谢您花时间查看此主题。抱歉我的英文。