Code:
#include <windows.h>
#include <vfw.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
char szAppName[] = "Name" ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
RegisterClass (&wndclass) ;
hwnd = CreateWindow (szAppName, "Fenstername", WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION,
0, 0, 500, 500,
NULL, NULL, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance;
static HWND hwndVideo;
switch (iMsg)
{
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam) -> hInstance;
hwndVideo = capCreateCaptureWindow((LPSTR)"WebCam",
WS_CHILD| WS_VISIBLE | WS_MAXIMIZE,
0, 0, CW_USEDEFAULT, CW_USEDEFAULT,(HWND) hwnd, (int) 3);
if(!capDriverConnect(hwndVideo,0))
{
MessageBox(hwnd,"Treiber konnte nicht geladen werden!","Treiberfehler",MB_ICONERROR);
SendMessage(hwnd,WM_DESTROY,0,0);
return 0;
}
capPreviewRate(hwndVideo,20);
capPreview(hwndVideo,TRUE);
capSetCallbackOnFrame(hwndVideo,FrameCallbackProc);
return 0 ;
/*case WM_PAINT:
return 0;*/
case WM_DESTROY:
capPreview(hwndVideo,FALSE);
capDriverDisconnect(hwndVideo);
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam) ;
}
LRESULT CALLBACK FrameCallbackProc(HWND hwnd, LPVIDEOHDR lpVHdr)
{
/*hier müsste ich jetzt das bild auswerten. die bilddaten sind zwar in lpVHdr aber ich weis net wie ich da rankomme*/
return TRUE;
}
würde mich freuen wenn mir einer helfen kann
Lesezeichen