본문 바로가기
코스웨어

(작성중) 20151124 - 주재민

by 알 수 없는 사용자 2015. 11. 24.
728x90
반응형

#include <vfw.h>

비디오 영상처리를 위한 것

 

 

 

 

vfw32추가

 

#include <windows.h>
#include <vfw.h>

//#pragma comment(lib,"vfw32.lib")
typedef struct
{
 UINT    uiMSG;
 LRESULT(*fp)  (HWND, WPARAM, LPARAM);

}stMSG_Map;


LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

LRESULT On_Paint(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT On_Create(HWND hWnd, WPARAM wParam, LPARAM lParam);
LRESULT On_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam);

 

HINSTANCE g_hInst;
LPSTR lpszClass = L"영상처리";

stMSG_Map stMap[] = {
 { WM_PAINT, On_Paint },
 { WM_CREATE, On_Create },
 { WM_DESTROY, On_Destroy },
 { WM_NULL, 0 }
};

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance
 , LPSTR lpszCmdParam, int nCmdShow)
{
 HWND hWnd;
 MSG Message;
 WNDCLASS WndClass;
 g_hInst = hInstance;

 WndClass.cbClsExtra = 0;
 WndClass.cbWndExtra = 0;
 WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
 WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
 WndClass.hInstance = hInstance;
 WndClass.lpfnWndProc = (WNDPROC)WndProc;
 WndClass.lpszClassName = lpszClass;
 WndClass.lpszMenuName = NULL;
 WndClass.style = CS_HREDRAW | CS_VREDRAW;
 RegisterClass(&WndClass);

 hWnd = CreateWindow(lpszClass, lpszClass, WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  NULL, (HMENU)NULL, hInstance, NULL);
 ShowWindow(hWnd, nCmdShow);

 while (GetMessage(&Message, 0, 0, 0)) {
  TranslateMessage(&Message);
  DispatchMessage(&Message);
 }
 return Message.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
 stMSG_Map * stpMap = stMap;

 while (WM_NULL != ((*stpMap).uiMSG))
 {
  if (iMessage == ((*stpMap).uiMSG))
  {
   return (((*stpMap).fp)(hWnd, wParam, lParam));
  }
  ++stpMap;
 }


 return(DefWindowProc(hWnd, iMessage, wParam, lParam));
}

LRESULT On_Paint(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
 HDC hdc;
 PAINTSTRUCT ps;

 BeginPaint(hWnd, &ps);
 EndPaint(hWnd, &ps);

 return 0;
}

LRESULT On_Create(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
 HWND hCamera;
 BITMAPINFO  stBMPinfo;

 hCamera = capCreateCaptureWindow(TEXT("CAM"),
  WS_CHILD | WS_VISIBLE,
  0, 0,
  320, 240,
  hWnd, 0);
 capDriverConnect(hCamera, 0);
 capPreviewRate(hCamera, 1);  // 화면에 보이는 속도
 capGetVideoFormat(hCamera, &stBMPinfo, 320 * 240);
 stBMPinfo.bmiHeader.biWidth = 320;
 stBMPinfo.bmiHeader.biHeight = 240;
 capSetVideoFormat(hCamera, &stBMPinfo, 320 * 240);
 capPreview(hCamera, TRUE);

 return 0;
}
LRESULT On_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
 

 return 0;
}

 

 

 

StretchDIBits function

728x90