📄 dlgcamera.cpp
字号:
// DlgCamera.cpp : implementation file
//
#include "stdafx.h"
#include "capture.h"
#include "DlgCamera.h"
#include "capture1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString InfoBuff;
extern HWND g_DlgHWND;
extern HANDLE g_DecodeEven;
int g_Pause;
extern void Decode();
extern int savetobmpfile(unsigned char *buf,
unsigned int len,
unsigned int width,
unsigned int height,
unsigned int bpp,
const char *path);
/////////////////////////////////////////////////////////////////////////////
// CDlgCamera dialog
CDlgCamera::CDlgCamera(CWnd* pParent /*=NULL*/)
: CDialog(CDlgCamera::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgCamera)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgCamera::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgCamera)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgCamera, CDialog)
//{{AFX_MSG_MAP(CDlgCamera)
ON_BN_CLICKED(IDC_PAUSE, OnPause)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_MESSAGE(WM_DECODESUCC, ShowResult)
ON_MESSAGE(WM_SHOWINFO, ShowInfo)
ON_BN_CLICKED(IDC_INIT, OnInit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgCamera message handlers
BOOL CDlgCamera::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if((WM_KEYDOWN == pMsg->message) && (FALSE == g_IsContinuous))
{
if(((VK_F4 == pMsg->wParam) || (VK_F3 == pMsg->wParam)) && (0 == g_KeyPressed))
{
g_KeyPressed = 1;
SetEvent(g_DecodeEven);
// SetDlgItemText(IDC_INFO, _T(""));
NKDbgPrintfW(TEXT("\t\t\tKeyDown\r\n"));
}
}
else if(WM_KEYUP == pMsg->message)
{
if((VK_F4 == pMsg->wParam) || (VK_F3 == pMsg->wParam))
{
g_KeyPressed = 0;
NKDbgPrintfW(TEXT("\t\t\tKeyUp\r\n"));
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CDlgCamera::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
g_DlgHWND = GetSafeHwnd();
g_Pause = FALSE;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgCamera::ShowResult(WPARAM wParam,LPARAM lParam)
{
CString Info;
Info.Format(TEXT("%s"), (char *)lParam);
SetDlgItemText(IDC_INFO, Info);
if(!g_IsContinuous)
{
savetobmpfile(g_PicBuff,
640*480,
640,
480,
8,
".\\cap-raw.bmp");
}
}
void CDlgCamera::OnPause()
{
// TODO: Add your control notification handler code here
HANDLE HDecodeThread;
if(FALSE == g_Pause)
{
g_Pause = TRUE;
g_StartDecode = FALSE;
PauseCapture();
SetDlgItemText(IDC_PAUSE, _T("Continue"));
}
else
{
g_Pause = FALSE;
g_StartDecode = TRUE;
ContinueCapture();
HDecodeThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Decode,NULL,0,NULL);
CloseHandle(HDecodeThread);
SetDlgItemText(IDC_PAUSE, _T("Pause"));
}
}
void CDlgCamera::OnSave()
{
if(g_Pause == FALSE)
{
OnPause();
}
// TODO: Add your control notification handler code here
SavePic(g_PicBuff);
if(savetobmpfile(g_PicBuff,
640*480,
640,
480,
8,
".\\cap-raw.bmp") >= 0)
{
SetDlgItemText(IDC_STATUS, _T("Save bmp file SUCC"));
}
}
void CDlgCamera::ShowInfo(WPARAM wParam,LPARAM lParam)
{
SetDlgItemText(IDC_STATUS, InfoBuff);
}
void CDlgCamera::OnInit()
{
// TODO: Add your control notification handler code here
InitCapture();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -