CString FilePathName;
CString strTime;
CTime tm;
tm = CTime::GetCurrentTime();
strTime = tm.Format("%Y%m%d%H%M%S");
FilePathName = strTime + _T(".bmp");
// 设置过滤器
TCHAR szFilter[] = _T("BMP Files (*.bmp)|*.bmp|JPG Files (*.jpg)|*.jpg|JPEG Files (*.jpeg)|*.jpeg|TIFF Files(.tif)|*.tif||");
// 构造保存文件对话框
CFileDialog fileDlg(FALSE, _T(""), strTime, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);
// 显示保存文件对话框
if (IDOK == fileDlg.DoModal())
{
// 如果点击了文件对话框上的“保存”按钮,则将选择的文件路径显示到编辑框里
FilePathName = fileDlg.GetPathName();
char* ttt;
LPCTSTR p = FilePathName.GetBuffer(0);
FilePathName.ReleaseBuffer();
ttt = new char[FilePathName.GetLength() + 1];
strcpy_s(ttt, FilePathName.GetLength() + 1, CT2CA(p));
cvSaveImage(ttt, Cur_Frame);
}
图像保存到指定路径,CString转char*
最新推荐文章于 2022-08-10 15:17:09 发布