이미지를

 

실행파일이 있는 디렉토리에 image 디렉토리를 생성하여

 

현재날짜_현재시간의 파일명으로 저장하는 함수


void Ccv_mfctestDlg::OnBnClickedButtSave()
{
	// TODO: Add your control notification handler code here
	CTime cTime = CTime::GetCurrentTime();

	const char* savefile;
	CString saveName;
	saveName.Format(_T("\\%04d%02d%02d_%02d%02d%02d.jpg"), 
		cTime.GetYear(), cTime.GetMonth(), cTime.GetDay(), 
		cTime.GetHour(), cTime.GetMinute(), cTime.GetSecond());

	TCHAR folderPath[500];
	GetModuleFileName(NULL, folderPath, MAX_PATH);

	CString strFilePath;
	strFilePath.Format(_T("%s"), folderPath);
	strFilePath = strFilePath.Left(strFilePath.ReverseFind('\\'));

	CFileFind file;
	CString strfolder = _T("image");
	CString strFile = _T("*.*");
	BOOL bResult = file.FindFile(strfolder + strFile);

	CString path;
	path.Format(_T("%s\\%s"), strFilePath, strfolder);

	if (!bResult)
	{
		bResult = CreateDirectory(path + "\\", NULL);
	}
	
	saveName = path + saveName;
	USES_CONVERSION;
	savefile = T2A((LPCTSTR)saveName);
	cvSaveImage(savefile, m_pImage);
}

+ Recent posts