Directx 8 Screen Capture
Posted: Thu Mar 23, 2006 7:31 pm
Hello all... I have been working on a screen capture program, but I'm having some issues with the GDI method of Capturing the screen. Basically it's too slow. ABout 50MS to get the screen from memory.
I have heard the Directx Method of capturing is much faster, the problem is I'm no Direct X Guru.
This method uses the getfrontbuffer() method to get the videobuffer to memory.
Here is some code I found on the net.
This would be patricularly useful for those people who want to get screen shots out of their Directx game. I think this Method Requires Directx 8.
I would appreciate any help any one could offer.
I have heard the Directx Method of capturing is much faster, the problem is I'm no Direct X Guru.
This method uses the getfrontbuffer() method to get the videobuffer to memory.
Here is some code I found on the net.
Code: Select all
Public Sub SaveScreenShot(ByVal sFilename As String)
Dim oSurface As Direct3DSurface8
Dim SrcPalette As PALETTEENTRY
Dim SrcRect As RECT
Dim DispMode As D3DDISPLAYMODE
'get display dimensions
g_oDevice.GetDisplayMode DispMode
'create a surface to put front buffer on,
'GetFrontBuffer always returns D3DFMT_A8R8G8B8
Set oSurface = g_oDevice.CreateImageSurface(DispMode.Width, _
DispMode.Height, _
D3DFMT_A8R8G8B8)
'get data from front buffer
g_oDevice.GetFrontBuffer oSurface
'we are saving entire area of this surface
With SrcRect
.Left = 0
.Right = DispMode.Width
.Top = 0
.Bottom = DispMode.Height
End With
'save this surface to a BMP file
g_oD3DX.SaveSurfaceToFile sFilename, _
D3DXIFF_BMP, _
oSurface, _
SrcPalette, _
SrcRect
End Sub
I would appreciate any help any one could offer.