Results 1 to 13 of 13

Thread: Taking a Screenshot of a Fullscreen Game

  1. #1
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23

    Taking a Screenshot of a Fullscreen Game

    Hey,

    I have... i guess a big problem...

    I'm trying to capture and save a screenshot of a full screen game (counter strike source) to be exact.
    I have tried many ways but all I ever get it a black screen or my desktop.

    I'm trying to take a screenshot once every 30 seconds in a timer.

    Any help would be appreciated...

    Cheers.

  2. #2
    Lotok is offline VB.NET Forum Genius
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2012
    Location
    Scotland
    Posts
    193
    Reputation
    22
    What code do you have so far? Check put this library for capturing direct x

    +++ removed link +++
    Posted wrong link, will amend when I get home.


    Sent from my XT910 using Tapatalk 2
    Last edited by Lotok; 05-12-2012 at 6:53 AM.

  3. #3
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    Hey,

    Im not sure how that would help that seems to be for playing AVIs.
    Right now I'm using VB.NET - Screenshot to jpeg... - VBForums
    I have disabled aero and it still doesnt work.
    Anyone have any ideas?

    Cheers

  4. #4
    Lotok is offline VB.NET Forum Genius
    .NET Framework
    .NET 4.0
    Join Date
    Jan 2012
    Location
    Scotland
    Posts
    193
    Reputation
    22
    You need to capture direct x

    Sent from my XT910 using Tapatalk 2

  5. #5
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    Yeah i know that...

    I am asking how.

  6. #6
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    Anyone know how to screenshot DX games???

  7. #7
    Herman is offline VB.NET Forum Miyagee
    .NET Framework
    .NET 4.0
    Join Date
    Oct 2011
    Location
    Montreal, QC, CA
    Posts
    448
    Reputation
    346
    You would need to use the DirectX SDK (deprecated) or the XNA SDK, both can be downloaded from Microsoft. The video card has to do the work, Windows cannot do it by itself.

  8. #8
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    Would you have any idea what sort of code i would need?

    And how I import it into VB?
    Last edited by D4RKKNIGH7; 05-14-2012 at 12:10 AM.

  9. #9
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23

    Direct3D Capture & Mixed mode assembly

    So far i have this code

    Code:
    Imports System.IOImports Microsoft.DirectX
    Imports Microsoft.DirectX.Direct3D
    
    
    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, 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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            CaptureScreenshot(Device, "capture.jpg", Direct3D.ImageFileFormat.Bmp)
        End Sub
    End Class
    Which I got from here (windows - DirectX 10 Screen Capture for Battlefield 3 - Stack Overflow)

    Except
    Code:
    CaptureScreenshot(Device, "capture.jpg", Direct3D.ImageFileFormat.Bmp)
    What do i put as the device???

    EDIT:
    I have added
    Code:
    Dim D3DDev As Device = Nothing  
     D3DDev = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing)
    And it seems to work but when i run the application and press button1 i get
    Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

  10. #10
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,186
    Reputation
    2368
    First result for web search your last quote was this Mixed mode assembly is built against version ... cannot be loaded in the 4.0 runtime without additional configuration information that says something about useLegacyV2RuntimeActivationPolicy configuration.

  11. #11
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    I have got the application to load now, but the code

    Code:
    Dim D3DDev As Device = Nothing D3DDev = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing)
    Does not work, how do i get my device?
    Last edited by D4RKKNIGH7; 05-14-2012 at 5:34 PM.

  12. #12
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    Hello,

    As of now i have got my application taking Screenshots outside of the game... but it only takes them of black screen
    And when I ingame i get
    Code:
    A first chance exception of type 'Microsoft.DirectX.Direct3D.DeviceLostException' occurred in Microsoft.DirectX.Direct3D.dll
    on this line
    Code:
     D3DDev = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing, present)

    This is the code i'm using


    Imports System.IO
    Imports Microsoft.DirectX
    Imports Microsoft.DirectX.Direct3D


    Public Class Form1
    Dim i As Integer = 0
    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, 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 SCREENCAP()
    Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
    Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height


    Dim present As New PresentParameters
    present.BackBufferCount = 1 'the number of backbuffer
    present.BackBufferFormat = Manager.Adapters(0).CurrentDisplayMode.Format
    present.BackBufferHeight = intY
    present.BackBufferWidth = intX
    present.Windowed = True
    present.SwapEffect = SwapEffect.Discard


    Dim D3DDev As Direct3D.Device
    D3DDev = New Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, Me.Handle, CreateFlags.SoftwareVertexProcessing, present)


    CaptureScreenshot(D3DDev, "c:\capture" & i & ".jpg", Direct3D.ImageFileFormat.Bmp)
    i = i + 1
    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    SCREENCAP()
    End Sub
    End Class


    I'm not really sure what I am doing, never worked with directX or screen capturing before
    Any help would be awesome.
    Im trying to take fullscreen captures of games.

  13. #13
    D4RKKNIGH7 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Sep 2011
    Posts
    12
    Reputation
    23
    asdasdagdrfyhzdyh
    Last edited by D4RKKNIGH7; 05-26-2012 at 7:45 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking