處理“快照”按鈕的單擊事件,截取當(dāng)前預(yù)覽圖像,并根據(jù)選擇的類型保存成相應(yīng)的文件。代碼如下:
void CCaptureDlg::OnSnapshot()
{
if(CPreView::m_CurIndex != -1) //判斷是否有預(yù)覽窗口
{
if(m_Frame.m_pList[CPreView::m_CurIndex].m_ShowImage)
{
CButton* pBmpButton = (CButton*)GetDlgItem(IDC_BMP);
if(pBmpButton->GetCheck() != 0) //獲取BMP單選按鈕的狀態(tài)
{
//創(chuàng)建文件保存對(duì)話框
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
{
//創(chuàng)建文件保存對(duì)話框
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("當(dāng)前選擇的圖像不能預(yù)覽!","提示");
}
}
}