处理“快照”按钮的单击事件,截取当前预览图像,并根据选择的类型保存成相应的文件。代码如下:
void CCaptureDlg::OnSnapshot()
{
if(CPreView::m_CurIndex != -1) //判断是否有预览窗口
{
if(m_Frame.m_pList[CPreView::m_CurIndex].m_ShowImage)
{
CButton* pBmpButton = (CButton*)GetDlgItem(IDC_BMP);
if(pBmpButton->GetCheck() != 0) //获取BMP单选按钮的状态
{
//创建文件保存对话框
CFileDialog fDlg(FALSE,"bmp","bmp_001",OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT,"bmp|*.bmp",this);
if(fDlg.DoModal() == IDOK)
{
CString fName = fDlg.GetPathName(); //获得文件的保存路径
VCASaveAsBmpFile(CPreView::m_CurIndex,fName); //保存为BMP文件
}
}
else
{
//创建文件保存对话框
CFileDialog fDlg(FALSE,"jpg","jpg_001",OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT,"JPG|*.JPG",this);
if(fDlg.DoModal() == IDOK)
{
CString fName = fDlg.GetPathName(); //获得文件的保存路径
VCASaveAsJpegFile(CPreView::m_CurIndex,fName); //保存为JPG文件
}
}
}
else
{
MessageBox("当前选择的图像不能预览!","提示");
}
}
}