Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define _CRT_SECURE_NO_DEPRECATE
  3. #include <stdbool.h>
  4. #include <stdio.h>
  5. #include <windows.h>
  6. #include <vfw.h>
  7.  
  8. bool webcam_image_simple(const char *filename)
  9. {
  10.     bool rc = false;
  11.     HWND hWnd = capCreateCaptureWindow("capture", WS_POPUP, 0, 0, 640, 480,
  12.         NULL,.0);
  13.     if (hWnd) {
  14.         SendMessage(hWnd, WM_CAP_DRIVER_CONNECT, 0, 0);
  15.         rc = (bool) SendMessage(hWnd, WM_CAP_FILE_SAVEDIB, 0, (LPARAM) filename);
  16.         SendMessage(hWnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);
  17.         SendMessage(hWnd, WM_CLOSE, 0, 0);
  18.     }
  19.     return rc;
  20. }
  21.  
  22. int main(void)
  23. {
  24.     printf("Acquiring image: %s\n", webcam_image_simple("test.bmp") ? "suceess" : "error");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement