Jump to content
Maximus

VB.NET DirectX Screen Capture

Recommended Posts

Posted (edited)

Am codul :


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

Public Class form1
Public GraphicsDevice As Direct3D.Device = Nothing
Public presentParams As PresentParameters = New PresentParameters

Public Sub InitializeGraphics()

Dim current As Format = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format
presentParams.SwapEffect = SwapEffect.Discard
presentParams.BackBufferFormat = current
presentParams.Windowed = True
presentParams.BackBufferHeight = 0
presentParams.BackBufferWidth = 0
GraphicsDevice = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)

End Sub

Public Function CaptureScreenshot(ByVal Device As Direct3D.Device, ByVal Filename As String, ByVal ImageFormat As Direct3D.ImageFileFormat) As Boolean
Dim Ssurface As Direct3D.Surface
Dim current As Format = Direct3D.Manager.Adapters(0).CurrentDisplayMode.Format

Ssurface = Device.GetBackBuffer(0, 0, BackBufferType.Mono)
Direct3D.SurfaceLoader.Save(Filename, ImageFormat, Ssurface)
Ssurface.Dispose()
Return True
End Function


Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
Dim cc As Integer = 1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
InitializeGraphics()
CaptureScreenshot(GraphicsDevice, cc & ".bmp", ImageFileFormat.Bmp)
cc += 1
End Sub
End Class

Incerc sa fac un screenshot cand joc battlefield 3. din cate am inteles doar folosind directx merge facut screenshot-ul.

Cand dau Debug imi da :

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.

si nu inteleg dc.

Ma poate ajuta cineva?? Multumesc anticipat.

//

Ok, am ajuns pana aici ... si tot nu merge

Edited by Maximus

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...