alors g trouvé comment faire :
voila apres quelques recherche sur le net et quelque modification perso.
le programme permet le prévisualisation, le stop motion et bien sur la capture de BMP.
sous Code::Block il faut pas oublier de faire le lien vers la bibliotheque vfw.f
settings --> compiler and debugger --> linker setting --> add : "Vfw32"
#include <windows.h>
#include <stdio.h>
#include <vfw.h>
LRESULT CALLBACK WindowProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK capVideoStreamCallback(HWND,LPVIDEOHDR);
PBITMAPINFO CreateBitmapInfoStruct(HWND, HBITMAP);
void CreateBMPFile(HWND, LPTSTR, PBITMAPINFO, HBITMAP, HDC);
char szAppName [] = TEXT("WebCam");
HWND camhwnd;
HDC hdc ;
HDC hdcMem;
PAINTSTRUCT ps;
HBITMAP hbm;
RECT rc;
int i=0;
//WinMain -- Main Window
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
HWND hwnd;
MSG msg;
WNDCLASS wc;
wc.style = CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(GetModuleHandle(NULL), IDI_APPLICATION);
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szAppName;
RegisterClass (&wc);
// Create the window
hwnd = CreateWindow (szAppName,szAppName,WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX,CW_USEDEFAULT,CW_USEDEFAULT,700,600,0,0,hInstance,0);
ShowWindow (hwnd,SW_SHOW);
UpdateWindow (hwnd);
while (GetMessage(&msg,0,0,0)){
if (!IsDialogMessage(hwnd, &msg)){
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
//Main Window Procedure WindowProc
LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HINSTANCE hInstance = GetModuleHandle(NULL);
HWND hButtStartCam;
HWND hButtStopCam;
HWND hButtGrabFrame;
HWND hButtVideo;
switch (message){
case WM_CTLCOLORSTATIC:
SetBkMode(hdc,TRANSPARENT);
return (LRESULT)CreateSolidBrush(0xFFFFFF);
case WM_CREATE:{
hButtStartCam = CreateWindowEx(0,"BUTTON","Start Camera",WS_CHILD | WS_VISIBLE,0,0,100,20,hwnd,(HMENU)1,hInstance, 0);
hButtStopCam = CreateWindowEx(0,"BUTTON","Stop Camera",WS_CHILD | WS_VISIBLE,0,25,100,20,hwnd,(HMENU)2,hInstance, 0);
hButtGrabFrame = CreateWindowEx(0,"BUTTON","Stop Motion",WS_CHILD | WS_VISIBLE,0,50,100,20,hwnd,(HMENU)3,hInstance, 0);
hButtGrabFrame = CreateWindowEx(0,"BUTTON","Photo",WS_CHILD | WS_VISIBLE,0,75,100,20,hwnd,(HMENU)4,hInstance, 0);
camhwnd = capCreateCaptureWindow ( NULL, WS_CHILD | WS_VISIBLE, 0, 100, 640,480, hwnd, 0);
capDriverConnect (camhwnd, 0); //connecte a une camera si plusieur disponibles vous propose un choix de la camera
//pas obligatoire
//if(!capDlgVideoSource(camhwnd)) //choisir la camera
// printf("erreur_01\n");
//else printf("vraie_01\n");
break;
}
case WM_COMMAND:{
switch (LOWORD(wParam)){
case 1:{
capDriverConnect (camhwnd, 0);
capPreview(camhwnd, TRUE);
capPreviewRate(camhwnd, 15);
capPreviewScale(camhwnd,TRUE);
capCaptureSingleFrameOpen(camhwnd);
break;
}
case 2:{
BITMAPINFO psVideoFormat;
capGetVideoFormat(camhwnd, &psVideoFormat,sizeof(psVideoFormat));
psVideoFormat.bmiHeader.biWidth = 640;
psVideoFormat.bmiHeader.biHeight = 480;
capSetVideoFormat(camhwnd, &psVideoFormat,sizeof(psVideoFormat));
capDriverDisconnect (camhwnd);
capFileSaveAs(camhwnd,"file.avi");
capCaptureSingleFrameClose(camhwnd);
break;
}
case 3:{
capCaptureSingleFrame(camhwnd);
break;
}
case 4:{
char nom[20];
i++;
wsprintf(nom,"frame_%d.bmp",i);
capGrabFrameNoStop(camhwnd);
if(capEditCopy(camhwnd))
{
capFileSaveDIB(camhwnd,nom);
}else i--;
break;
}
}
break;
}
case WM_DESTROY:{
PostQuitMessage(0);
break;
}
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
voila pour les question n'esitez pas je repondrais a ce que je peux.