Hi from Spain. This is possible that this you is useful. This code, in full screen mode, capture the backbuffer and save in to a surface. In windowed mode capture only the client area of the window, without title bar and borders. Before, you can save this surface in to a BMP file with D3DX.SaveSurfaceToFile(). This code run under VB 6.0 and DirectX8, theoretically also it's compatible with DirectX9:
Public Function SURF_ScreenCapture() As Long
On Error GoTo ErrOut
Dim oSurface As Direct3DSurface8
Dim Pal As PALETTEENTRY
Dim SrcRect As RECT
Dim DispMode As D3DDISPLAYMODE
Dim ClientRect As POINTAPI
Dim Surf As Long
If D3D_Init Then
Surf = SURF_Create(D3DWindow.BackBufferWidth, D3DWindow.BackBufferHeight)
If Surf < 0 Then GoTo ErrOut
If Not Windowed Then
D3DDevice.GetFrontBuffer Surface(Surf).Surface
Else D3DDevice.GetDisplayMode DispMode
Set oSurface = D3DDevice.CreateImageSurface(DispMode.Width, _
DispMode.Height, _
D3DFMT_A8R8G8B8)
D3DDevice.GetFrontBuffer oSurface
Call GetClientRect(Me.hwnd, SrcRect)
Call ClientToScreen(Me.hwnd, ClientRect)
With SrcRect
.Left = ClientRect.X
.Right = .Left + .Right
.Top = ClientRect.Y
.bottom = .Top + .bottom
End With
Call D3DX.LoadSurfaceFromSurface(Surface(Surf).Surface, Pal, ByVal 0, oSurface, Pal, SrcRect, D3DX_DEFAULT, 0)
End If
SURF_ScreenCapture = Surf
End If
Exit Function
ErrOut:
SURF_ScreenCapture = -1
End Function
I hope that it you is useful ;)
Chao...