Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Screen Capture
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

waynehell
Neophyte

1 Posts

Posted - Oct 19 2005 :  1:09:16 PM  Show Profile  Reply with Quote
Help.!! Please. How can i capture a screen in a directx application and send it to the clipboard??

Eric Coleman
Gladiator

USA
811 Posts

Posted - Oct 19 2005 :  2:15:55 PM  Show Profile  Visit Eric Coleman's Homepage  Reply with Quote
Which version of VB are you using and which version of DirectX?

Go to Top of Page

EX3
Neophyte

Spain
2 Posts

Posted - Oct 19 2005 :  10:45:36 PM  Show Profile  Visit EX3's Homepage  Reply with Quote
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:
'This code is a part of the dx_lib32 2.0: (sorry, the coments are in spanish)
'-----------------------------------------------------------------------
  
'Realiza una captura de pantalla y la guarda en memoria:
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
    'Creamos la superficie donde almacenaremos la captura:  
    Surf = SURF_Create(D3DWindow.BackBufferWidth, D3DWindow.BackBufferHeight)  
  
    If Surf < 0 Then GoTo ErrOut '// Replace with a Error.Raise() function for example ;) //  
  
    If Not Windowed Then 'FullScreen:  
  
        'Leemos el contenido de la pantalla (FrontBuffer) y lo guardamos en la superficie:  
        D3DDevice.GetFrontBuffer Surface(Surf).Surface  
  
    Else 'Windowed:  
        'Obtenemos las dimensiones de la resolucion de pantalla del adaptador:  
        D3DDevice.GetDisplayMode DispMode  
  
        'Creamos una superficie con la resolucion seleccionada del adaptador grafico a  
        '32 Bit de color por que la funcion siempre devuelve el resultado a 32 Bits (D3DFMT_A8R8G8B8):  
        Set oSurface = D3DDevice.CreateImageSurface(DispMode.Width, _  
                DispMode.Height, _  
                D3DFMT_A8R8G8B8)  
  
        'Leemos el contenido de la pantalla (FrontBuffer) y lo guardamos en la superficie:  
        D3DDevice.GetFrontBuffer oSurface  
  
        'En modo ventana la captura es de toda la pantalla, escritorio incluido, asi que calculamos  
        'la posicion y las dimensiones del area de cliente de la ventana donde dibujamos para salvar  
        'unicamente el contenido del programa:  
  
        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
  
        'Copiamos la seccion de captura del programa a la superficie en memoria:  
        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...

Sorry for my bad english ;)

dx_lib32 2.0 - Comming soon, and also, it's possible, in english (http://dxlib32.se32.com)
Go to Top of Page

EX3
Neophyte

Spain
2 Posts

Posted - Oct 19 2005 :  10:58:35 PM  Show Profile  Visit EX3's Homepage  Reply with Quote
quote:
Originally posted by EX3

'Creamos la superficie donde almacenaremos la captura:
    Surf = SURF_Create(D3DWindow.BackBufferWidth, D3DWindow.BackBufferHeight)  


Sorry, the SURF_Create() is an own function of my project, it's used the D3DDevice.CreateImageSurface() function to create the new surface. You are going to have to adapt a bit the code for your objetive.

Chao...

Sorry for my bad english ;)

dx_lib32 2.0 - Comming soon, and also, it's possible, in english (http://dxlib32.se32.com)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.2 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.