Code: Select all
/*
Example the class TCapCapture for Fivewin
(c)2003 by Rafa Carmona( Thefull )
Software under Licencia GPL. http://www.gnu.org para saber mas.
( Tiene la misma exception que [x]Harbour )
*/
#INCLUDE "Fivewin.CH"
Function Main()
Local a,x
Local oWnd, oCapture, nRate := 10, oMenu, nFrames := 15
LOCAL aDrivers
LOCAL i
MENU oMenu
MENUITEM "FramesPerSec" ACTION ( MsgGet("Frames","Frames Per Second:",@nFrames),oCapture:FramesPerSec(nFrames) )
MENUITEM "Rate View" ACTION ( MsgGet("Rate Preview","Rate Preview:",@nRate),oCapture:PreviewRate( nRate ))
MENUITEM "Video Setup" ACTION oCapture:SetupVideo()
MENUITEM "Video Compress" ACTION oCapture:VideoCompression()
MENUITEM "Start Capture" ACTION ( oCapture:SetFile(".\pepe.avi") ,;
oCapture:StartCapture() )
MENUITEM "Stop Capture" ACTION oCapture:StopCapture()
ENDMENU
DEFINE WINDOW oWnd TITLE "Cap-Fivewin (c)2003 by Rafa Carmona(Thefull)" MENU oMenu MDI
oCapture := TCapCapture():New( 25,25,320,240, oWnd , 0)
IF oCapture:Conect()
oCapture:PreviewRate( nRate )
oCapture:Preview(.T.)
* oCapture:Overlay( .T. )
ELSE
? "No connect.... ;( "
* oWnd:End()
ENDIF
// En fase de pruebas
/*
aDrivers := WC_Capturas()
? Len( aDrivers )
for i := 1 to Len( aDrivers )
? "Driver: " + aDrivers[i][1] + " Version: " + aDrives[i][2]
next
*/
ACTIVATE WINDOW oWnd
oCapture:End()
Return NIL
/*
Implemetation Class TCapCapture for Fivewin.
(c)2003 by Rafa Carmona( Thefull )
Beta 4
*/
CLASS TCapCapture FROM TControl
CLASSDATA lRegistered AS LOGICAL
DATA hWndC
DATA nIndex INIT 0 // By Default index first found
METHOD New() CONSTRUCTOR
METHOD Conect() INLINE ConectDriver( ::hWndC, ::nIndex )
METHOD End() INLINE DisConectDriver( ::hWndC )
METHOD StartCapture() INLINE Capture( ::hWndC )
METHOD StopCapture() INLINE CaptureStop( ::hWndC )
METHOD Preview( lPreview ) INLINE CapPreview( ::hWndC, lPreview )
METHOD PreviewRate( nRate ) INLINE CapPreviewRate( ::hWndC, nRate )
METHOD PreViewScale( lScale ) INLINE CapPreviewScale( ::hWndC,lScale )
METHOD CreateWndCapture()
METHOD FileSaveAs( cFileName ) INLINE CapFileSaveAs( ::hWndC, cFilename )
METHOD SetFile( cFile ) INLINE CapFileSetCaptureFile( ::hWndC, cFile )
METHOD SetupCapture() INLINE CapCaptureSetSetup( ::hWndC )
METHOD SetupVideo() INLINE SetupVideo( ::hWndC )
METHOD Overlay( lMode ) INLINE CapOverlay( ::hWndC, lMode )
METHOD FramesPerSec( nFrames ) INLINE CapFramesPerSec( ::hWndC, nFrames )
METHOD VideoCompression() INLINE CapDlgVideoCompression( ::hWndC )
METHOD ListDrivers()
END CLASS
METHOD New( nTop, nLeft, nWidth, nHeight, oWnd , nIndex ) CLASS TCapCapture
DEFAULT nTop := 0, nLeft := 0,;
oWnd := GetWndDefault(),;
nWidth := 200,;
nHeight := 200
::nTop := nTop
::nLeft := nLeft
::nBottom = ::nTop + nHeight - 1
::nRight = ::nLeft + nWidth - 1
::nStyle = nOR( WS_CHILD, WS_VISIBLE )
::nId = ::GetNewId()
::oWnd = oWnd
::nIndex := nIndex
::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
if ! Empty( oWnd:hWnd )
::Create()
::Default()
::lVisible = .t.
oWnd:AddControl( Self )
else
oWnd:DefControl( Self )
* ::lVisible = .f.
endif
IF ::ListDrivers() > 0
::CreateWndCapture()
ELSE
?"Not found Drivers..."
ENDIF
return Self
METHOD ListDrivers() CLASS TCapCapture
Local aDrivers := CapGetDrivers() , oCombo, cItem := ""
Local oDlg
* IF Len( aDrivers ) > 1 // Si hay mas de un driver , permite seleccionarlo
* DEFINE Dialog oDlg TITLE "Select Driver Capture"
// Se produce un GPF. Adivina por que ;(
* @1,1 COMBOBOX oCombo VAR cItem ITEMS aDrivers OF oDlg SIZE 100,100 ;
*VALID ( ::nIndex := oCombo:nAt - 1,.t. )
* ACTIVATE DIALOG oDlg
* ENDIF
Return( Len( aDrivers ) )
METHOD CreateWndCapture() CLASS TCapCapture
::hWndC := CaptureWin( "My First Capture FROM FIVEH!!!", ::nStyle,;
::nTop, ::nLeft, ::nWidth, ::nHeight, ::oWnd:hWnd, ::nIndex )
RETURN SELF
/*
Implementation language C for [x]Harbour
(c)2003 by Rafa Carmona ( Thefull )
Beta 4
*/
#pragma BEGINDUMP
#include <windows.h>
#include <vfw.h>
#include "hbapi.h"
HB_FUNC( CAPTUREWIN )
{
HWND VFWAPI hVentana = capCreateCaptureWindow( hb_parc( 1 ), (DWORD) hb_parnl( 2 ),
hb_parni( 3 ) ,hb_parni( 4 ),hb_parni( 5 ),hb_parni( 6 ),
(HWND) hb_parnl( 7 ), hb_parni(8) ) ;
hb_retnl( (LONG) hVentana ) ;
}
HB_FUNC( CAPTURE )
{
hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_SEQUENCE, 0, 0L) );
}
HB_FUNC( CAPTURESTOP )
{
hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_STOP, 0, 0L) );
}
HB_FUNC( CAPCAPTURESEQUENCENOFILE )
{
hb_retl( capCaptureSequenceNoFile( (HWND) hb_parnl(1) ) );
}
HB_FUNC( CONECTDRIVER )
{
// hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_DRIVER_CONNECT, 0 , 0L) );
hb_retl( capDriverConnect( (HWND) hb_parnl( 1 ), hb_parni(2) ) );
}
HB_FUNC( DISCONECTDRIVER )
{
hb_retl( capDriverDisconnect( (HWND) hb_parnl( 1 ) ));
}
HB_FUNC( CAPCAPTURESETSETUP )
{
CAPTUREPARMS Capture;
hb_retl( capCaptureSetSetup( (HWND) hb_parnl( 1 ), &Capture, sizeof( CAPTUREPARMS ) ));
}
HB_FUNC( CAPGRABFRAME )
{
hb_retl( capGrabFrame( (HWND) hb_parnl( 1 ) ) );
}
HB_FUNC( CAPFILESAVEAS )
{
hb_retl( capFileSaveAs( (HWND) hb_parnl(1), hb_parc( 2 )));
}
HB_FUNC( CAPFILESETCAPTUREFILE )
{
BOOL fResult;
fResult = capFileSetCaptureFile( (HWND)hb_parnl(1), (LPSTR) hb_parc(2) );
// preallocate a file of 5 MB.
capFileAlloc( (HWND) hb_parnl(1), (1024L * 1024L * 5));
hb_retl( fResult );
}
HB_FUNC( CAPPREVIEW )
{
hb_retl( capPreview( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ));
}
HB_FUNC( CAPPREVIEWSCALE )
{
hb_retl( capPreviewScale( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ));
}
HB_FUNC( CAPPREVIEWRATE )
{
hb_retl( capPreviewRate( (HWND) hb_parnl( 1 ), hb_parni( 2 ) ));
}
HB_FUNC( CAPDLGVIDEOSOURCE )
{
hb_retl( capDlgVideoSource( (HWND) hb_parnl( 1 ) ) );
}
HB_FUNC( CAPDLGVIDEODISPLAY )
{
hb_retl( capDlgVideoDisplay( (HWND) hb_parnl( 1 ) ) );
}
HB_FUNC( CAPDLGVIDEOCOMPRESSION )
{
hb_retl( capDlgVideoCompression( (HWND) hb_parnl(1)) );
}
HB_FUNC( SETUPVIDEO )
{
CAPDRIVERCAPS CapDriverCaps;
CAPSTATUS CapStatus;
capDriverGetCaps( (HWND) hb_parnl( 1 ), &CapDriverCaps, sizeof (CAPDRIVERCAPS));
// Video source dialog box.
if (CapDriverCaps.fHasDlgVideoSource)
capDlgVideoSource( (HWND) hb_parnl( 1 ) );
// Video format dialog box.
if (CapDriverCaps.fHasDlgVideoFormat)
{
capDlgVideoFormat( (HWND) hb_parnl( 1 ) );
// Are there new image dimensions?
capGetStatus( (HWND) hb_parnl( 1 ), &CapStatus, sizeof (CAPSTATUS));
// New Dimensions of Window
SetWindowPos( (HWND) hb_parnl( 1 ), NULL, 0, 0, CapStatus.uiImageWidth,
CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
// If so, notify the parent of a size change.
}
// Video display dialog box.
if (CapDriverCaps.fHasDlgVideoDisplay)
capDlgVideoDisplay( (HWND) hb_parnl( 1 ) );
}
HB_FUNC( CAPFRAMESPERSEC ) // hWnd, framesperSec
{
CAPTUREPARMS CaptureParms;
float FramesPerSec = (FLOAT)hb_parnl( 2 );
capCaptureGetSetup( (HWND)hb_parnl(1), &CaptureParms, sizeof(CAPTUREPARMS));
CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 / FramesPerSec);
hb_retl( capCaptureSetSetup( (HWND)hb_parnl(1), &CaptureParms, sizeof (CAPTUREPARMS)) );
}
HB_FUNC( CAPOVERLAY )
{
CAPDRIVERCAPS CapDrvCaps;
capDriverGetCaps( (HWND) hb_parnl( 1 ), &CapDrvCaps, sizeof (CAPDRIVERCAPS));
if (CapDrvCaps.fHasOverlay)
hb_retl( capOverlay( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ) );
else
hb_retl( FALSE );
}
HB_FUNC( CAPGETDRIVERS )
{
char szDeviceName[80];
char szDeviceVersion[80];
int wIndex;
// Maximos dispositivos a tratar. Del 0...9
hb_reta(10);
for (wIndex = 0; wIndex < 10; wIndex++)
{
if (capGetDriverDescription (wIndex, szDeviceName,
sizeof (szDeviceName), szDeviceVersion,
sizeof (szDeviceVersion)))
{
// Append name to list of installed capture drivers
// and then let the user select a driver to use.
//MessageBox( GetActiveWindow(), szDeviceName, szDeviceVersion, MB_SYSTEMMODAL );
hb_storc( szDeviceName , -1, ( wIndex + 1 ) );
}
}
}
// Codigo por Jose Lalin en base de pruebas.
// Gracias Jose!!!
#include "hbapiitm.h"
HB_FUNC( WC_CAPTURAS )
{
// He cambiado la declaracion porque capGetDrivers necesita un puntero
// a la memoria donde almacenar szDeviceName y szDeviceVersion
LPSTR szDeviceName[80];
LPSTR szDeviceVersion[80];
int wIndex;
int wDevices;
PHB_ITEM pReturn;
for( wIndex = 0; wIndex < 10; wIndex++ )
{
if( capGetDriverDescription( wIndex, szDeviceName,
sizeof( szDeviceName ), szDeviceVersion,
sizeof( szDeviceVersion ) ) )
{
wDevices = wIndex + 1;
}
}
pReturn = hb_itemArrayNew( wDevices );
for( wIndex = 0; wIndex < wDevices ; wIndex++ )
{
if( capGetDriverDescription( wIndex, szDeviceName,
sizeof( szDeviceName ), szDeviceVersion,
sizeof( szDeviceVersion ) ) )
{
PHB_ITEM pDriver = hb_itemPutC( NULL, (char*) szDeviceName );
PHB_ITEM pVersion = hb_itemPutC( NULL, (char*) szDeviceVersion );
PHB_ITEM pSub = hb_itemArrayNew( 2 );
hb_itemArrayPut( pSub, 1, pDriver );
hb_itemArrayPut( pSub, 2, pVersion );
hb_itemRelease( pDriver );
hb_itemRelease( pVersion );
hb_itemArrayPut( pReturn, wIndex + 1, pSub );
hb_itemRelease( pSub );
}
}
hb_itemReturn( pReturn );
hb_itemRelease( pReturn );
}
#pragma ENDDUMP