用CxImage保存圖片,遇到個問題,保存後的圖片是0字節,代碼如下:
BOOL CHalftoningDoc::OnSaveDocument(LPCTSTR lpszPathName){
// TODO: Add your specialized code here and/or call the base class
m_image.Save(lpszPathName,CXIMAGE_FORMAT_JPG);
return CDocument::OnSaveDocument(lpszPathName);
}
後來用了個笨辦法,解決了保存的問題,不過會彈出兩次對話框:
CString strFilter, fileName;
strFilter=_T("JPEG圖像文件|*.jpg||");
CFileDialog dlg(FALSE,_T("jpg"),lpszPathName,NULL,strFilter);
if(IDOK==dlg.DoModal())
{
fileName = dlg.GetPathName();
HRESULT hResult = m_image.Save(fileName, CXIMAGE_FORMAT_JPG);
}
return 0;
//return CDocument::OnSaveDocument(lpszPathName);
後來在網上查了下,捨棄第二種方法,第一個代碼按以下方法修改就可以了:
m_image.Save(lpszPathName,CXIMAGE_FORMAT_JPG);
return TRUE;
//return CDocument::OnSaveDocument(lpszPathName);
原因不清楚...請指點
注:保存時,需在彈出的對話框中輸入文件擴展名 .jpg