Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having trouble getting a screen capture when i play Battlefield3. I know that i must capture usig DirectX, so i have made some search and found this :

C#
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


but it does not work. It says :
Error 2 'Device' is a type and cannot be used as an expression.
Error 1 'DirectX' is not declared. It may be inaccessible due to its protection level.

I know that the game uses DirectX 11 / DirectX 10.
I am a member of a clan in BF3 and we want the program to take screen shots at a time interval, the timers is not a problem, i can do that but i can't manage to resolve the 2 errors. Thanks in advance and i appreciate the time you are spending to view this thread. Sorry for my English.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900