// NeroDlg1.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "NeroDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CNeroDlg* pDlg; CNeroDlg::CNeroDlg(CWnd* pParent /*=NULL*/) : CDialog(CNeroDlg::IDD, pParent) { m_bFromDir = 0; m_bDvd = 0; #ifdef USE_KERNEL_DLL m_nImgType = FImgtype; #endif m_checkphoto1 = 1; m_checkphoto2 = FALSE; m_checkphoto3 = FALSE; m_checkphoto4 = FALSE; m_checkphoto5 = FALSE; m_checkphoto6 = FALSE; m_hThread = NULL; m_hCtrl = NULL; pDlg = this; NowDoingBurn = false; m_nphotos = 0; m_nspase = 0; m_nphotos1 = 0; m_nspase1 = 0; m_nphotos2 = 0; m_nspase2 = 0; m_nphotos3 = 0; m_nspase3 = 0; m_nphotos4 = 0; m_nspase4 = 0; m_nphotos5 = 0; m_nspase5 = 0; m_nphotos6 = 0; m_nspase6 = 0; m_bScale = AfxGetApp()->GetProfileInt(LYFZVERSION, "cutphoto", 1); m_bDvd = AfxGetApp()->GetProfileInt(LYFZVERSION, "bDvd", 0); m_checkphoto1 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto1", 1); m_checkphoto2 = 0;//AfxGetApp()->GetProfileInt (LYFZVERSION, "m_checkphoto2", 0); m_checkphoto3 = 0;//AfxGetApp()->GetProfileInt (LYFZVERSION, "m_checkphoto3", 0); m_checkphoto4 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto4", 0); m_checkphoto5 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto5", 0); m_checkphoto6 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto6", 0); } void CNeroDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CNeroDlg) DDX_Control(pDX, IDC_COMBO1, m_combo1); DDX_Control(pDX, IDC_PROGRESS1, m_Progress); DDX_Radio(pDX, IDC_RADIO3, m_bFromDir); DDX_Radio(pDX, IDC_RADIO1, m_bDvd); DDX_Check(pDX, IDC_CHECK1, m_checkphoto1); DDX_Check(pDX, IDC_CHECK2, m_checkphoto2); DDX_Check(pDX, IDC_CHECK3, m_checkphoto3); DDX_Check(pDX, IDC_CHECK4, m_checkphoto4); DDX_Check(pDX, IDC_CHECK5, m_checkphoto5); DDX_Check(pDX, IDC_CHECK6, m_checkphoto6); DDX_Check(pDX, IDC_CHECK7, m_bScale); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CNeroDlg, CDialog) //{{AFX_MSG_MAP(CNeroDlg) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_BN_CLICKED(IDC_RADIO4, OnRadio4) ON_BN_CLICKED(IDC_BUTchoosedir, OnBUTchoosedir) ON_BN_CLICKED(IDC_CHECK1, OnCheck1) ON_BN_CLICKED(IDC_CHECK2, OnCheck2) ON_BN_CLICKED(IDC_CHECK3, OnCheck3) ON_BN_CLICKED(IDC_CHECK4, OnCheck4) ON_BN_CLICKED(IDC_CHECK5, OnCheck5) ON_BN_CLICKED(IDC_CHECK6, OnCheck6) ON_BN_CLICKED(IDC_CHECK7, OnCheck7) ON_CBN_CLOSEUP(IDC_COMBO1, OnCloseupCombo1) ON_BN_CLICKED(IDC_RADIO1, OnRadio1) ON_BN_CLICKED(IDC_RADIO2, OnRadio2) ON_WM_DESTROY() //}}AFX_MSG_MAP ON_BN_CLICKED(Btn_ExportToU, OnBnClickedExporttou) END_MESSAGE_MAP() // 需要处理分隔符产生的问题; BOOL CNeroDlg::OnInitDialog() { CDialog::OnInitDialog(); m_Progress.SetRange(0, 100); EnableCtrls(); CString filter = "id='" + m_strOrderNum + "'"; g_sendhead.bsql = 0; g_sendhead.code[0] = 50; // dindansp,需要处理分隔符产生的问题; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0) { return 1; } CArraysparray; DataToArray(&sparray); CString str, spname; CStringArray spnamearray; for (int i = 0; i < sparray.GetSize(); i++) { str = sparray.ElementAt(i).ElementAt(6); spname = sparray.ElementAt(i).ElementAt(5); GetNo(str, m_noarray); } m_combo1.AddString("1200x1600"); m_combo1.AddString("768x1024"); m_combo1.AddString("600x800"); m_combo1.AddString("480x640"); int pos = AfxGetApp()->GetProfileInt(LYFZVERSION, "cutphotosize", 2); m_combo1.SetCurSel(pos); if (m_checkphoto1)OnCheck1(); if (m_checkphoto2)OnCheck2(); if (m_checkphoto3)OnCheck3(); if (m_checkphoto4)OnCheck4(); if (m_checkphoto5)OnCheck5(); if (m_checkphoto6)OnCheck6(); CenterWindow(); return TRUE; } bool NERO_CALLBACK_ATTR CNeroDlg::IdleCallback(void *pUserData) { static MSG msg; while (!::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) { if (!AfxGetThread()->PumpMessage()) { break; } } return false; } NeroUserDlgInOut NERO_CALLBACK_ATTR CNeroDlg::UserDialog(void *pUserData, NeroUserDlgInOut type, void *data) { switch (type) { case DLG_AUTO_INSERT: return DLG_RETURN_CONTINUE; break; case DLG_DISCONNECT_RESTART: return DLG_RETURN_ON_RESTART; break; case DLG_DISCONNECT: return DLG_RETURN_CONTINUE; break; case DLG_AUTO_INSERT_RESTART: return DLG_RETURN_EXIT; break; case DLG_RESTART: return DLG_RETURN_EXIT; break; case DLG_SETTINGS_RESTART: return DLG_RETURN_CONTINUE; break; case DLG_OVERBURN: return DLG_RETURN_TRUE; break; case DLG_AUDIO_PROBLEMS: return DLG_RETURN_EXIT; break; case DLG_FILESEL_IMAGE: { // create filter for image files // create a CFileDialog object. // usage : CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, // DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, // CWnd* pParentWnd = NULL ); // // bOpenFileDialog = TRUE, create a File Open dialog // lpszDefExt = NULL, do not automatically append a file extension // dwFlags = OFN_OVERWRITEPROMPT, makes no sense during file open, // just in case we decide to use File Save later // szFilter = "Image Files (*.nrg)|*.nrg|All Files (*.*)|*.*||" // pParentWnd = ((CNeroFiddlesDlg*)pUserData), our current Dialog window is the parent // user canceled, do not proceed with the burn process return DLG_BURNIMAGE_CANCEL; } break; case DLG_WAITCD: { AfxMessageBox("光盘不为空或类型错误"); return DLG_RETURN_EXIT; break; } default: break; } // return DLG_RETURN_EXIT; } BOOL NERO_CALLBACK_ATTR CNeroDlg::ProgressCallback(void *pUserData, DWORD dwProgressInPercent) { ((CNeroDlg*)pUserData)->m_Progress.SetPos(dwProgressInPercent); return true; } BOOL NERO_CALLBACK_ATTR CNeroDlg::AbortedCallback(void *pUserData) { return false; return true; } void NERO_CALLBACK_ATTR CNeroDlg::AddLogLine(void *pUserData, NERO_TEXT_TYPE type, const char *text) { //((CNeroMFCappDlg*)pUserData)->AppendString("Log line:" +(CString)*text); return; } void NERO_CALLBACK_ATTR CNeroDlg::SetPhaseCallback(void *pUserData, const char *text) { return; } // 返回文件名; CString GetFileNameFromPath(CString strFilePath) { if ( strFilePath.IsEmpty()) return _T(""); static INT nIndex = 0; nIndex = strFilePath.ReverseFind(_T('\\')); if ( nIndex != -1 ) { strFilePath = strFilePath.Mid(nIndex + 1); } nIndex = strFilePath.ReverseFind(_T('.')); if ( nIndex != -1 ) { strFilePath = strFilePath.Left(nIndex); return strFilePath; } return _T(""); } void CNeroDlg::GenSPhoto(CString dir, CStringArray &array, DWORD &nNeedSpase, BOOL bCheckNo) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dir), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); CString str; for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; if (str.Right(2) == "ok")continue; if (bCheckNo) { if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1) continue; } if (m_bScale) { // 客户原片和修好的片,是硬编码,对于多目录的使用有影响! if (str.Find("客户原片") != -1 || str.Find("\\修好的片") != -1) { if (::FindArray(&m_noarray, GetFileNameFromPath(str)) != -1) { array.Add(str); CFile fp; fp.Open(str, CFile::modeRead); nNeedSpase += fp.GetLength(); fp.Close(); } } else { array.Add(str); CFile fp; fp.Open(str, CFile::modeRead); nNeedSpase += fp.GetLength(); fp.Close(); } } else array.Add(str); } } // Generate Samll Photo; void CNeroDlg::GenSPhoto(CString dir, CString sType, CStringArray &array, CStringArray &dirarray) { using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(dir), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); CString str; for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; if (str.Right(2) == "ok")continue; if (m_bScale && (sType == "(初修)" || sType == "(原片)")) { if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1) { ::CreateDirectory(g_mainpath + "\\temp", NULL); ::CreateDirectory(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)", NULL); CString dir; dir = g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)\\" + sType; ::CreateDirectory(dir, NULL); array.Add(str); dirarray.Add(dir); } } } } int GetChildCount(CString str, CStringArray &array) { CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1); int count = array.GetSize(); CString temp; for (int i = 0; i < array.GetSize(); i++) { if (array.ElementAt(i) == str) count--; else if (array.ElementAt(i).Find(str) == -1) count--; else { temp = array.ElementAt(i); temp = temp.Left(temp.ReverseFind('\\')); if (temp != str) count--; } } return count; } void CNeroDlg::OnCancel() { // TODO: Add extra cleanup here //printf("Jeff:EndofThread\n\n"); EndofThread(); // Jeff add. if (NowDoingBurn) //如果正在工作 则不能取消 { if (m_Burn.NeroBurnOK) { CDialog::OnOK(); return; } if (m_Burn.NeroWorkError) { CDialog::OnCancel(); return; } AfxMessageBox("已经开始刻录了,不能中断"); return; } CDialog::OnCancel(); //否则取消 } void CNeroDlg::DoBurnOrNot() { m_Burn.NeroAPIInit(); m_Burn.NeroAPIBurn(); } BOOL CNeroDlg::PreTranslateMessage(MSG* pMsg) { return CDialog::PreTranslateMessage(pMsg); } void CNeroDlg::EnableCtrls() { GetDlgItem(IDC_CHECK1)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_CHECK2)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_CHECK3)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_CHECK4)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_CHECK5)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_CHECK6)->EnableWindow(!m_bFromDir); GetDlgItem(IDC_BUTchoosedir)->EnableWindow(m_bFromDir); } void CNeroDlg::OnRadio3() { UpdateData(); EnableCtrls(); } /************************************************************************/ /* CheckBox:从电脑目录中选取; */ /************************************************************************/ void CNeroDlg::OnRadio4() { OnRadio3(); } void CNeroDlg::OnBUTchoosedir() { CString dir; GetSavePath(dir); dir.IsEmpty(); GetDlgItem(IDC_EDIT1)->SetWindowText(dir); m_photoarray7.RemoveAll(); CString path; path = dir; CStringArray dirarray; CString str; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } int i = 0; for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); m_photoarray7.Add(str); } } if (m_photoarray7.GetSize() == 0) { AfxMessageBox("警告:目录中无照片!", MB_ICONSTOP); } m_nphotos = m_photoarray7.GetSize(); m_nspase = 0; for (i = 0; i < m_photoarray7.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray7.ElementAt(i), CFile::modeRead)) { m_nspase += fp.GetLength(); fp.Close(); } } m_nspase /= (1024 * 1024); str.Format("照片:%d 占用空间:%dM", m_nphotos, m_nspase); GetDlgItem(IDC_STATIC7)->SetWindowText(str); } void CNeroDlg::OnCheck1() // 客人选中的照片(精修); { UpdateData(); if (m_checkphoto1) { if (m_photoarray1.GetSize() == 0) { INT i = 0; #ifdef USE_KERNEL_DLL CString str; INT nIndex = 0; DWORD dwReturnSize = 0; CStringArray AryLoadExtImgpath; CStringArray AryWithExtImgpath; CStringArray AryOrderDirectory; CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname); // 查找精修片目录; if ( GetOrderImgpathEx(FImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { m_nImgType = FImgtype; INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i)); } } } if ( m_photoarray1.GetSize() == 0 ) {// 精修片目录没有相片,查找初修片目录,以初修代替精修; m_nImgType = EImgtype; AfxMessageBox(_T("没有找到精修片,将用初修片替代!")); AryLoadExtImgpath.RemoveAll(); AryWithExtImgpath.RemoveAll(); AryOrderDirectory.RemoveAll(); if ( GetOrderImgpathEx(EImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; // 判断初修片是否是选中的相片; if ( FindArray(&m_noarray, GetFileNameFromPath(str)) != -1) m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i)); } } } } if ( m_photoarray1.GetSize() == 0 ) {// 初修片目录没有相片,查找原片目录,以原片代替精修; m_nImgType = OImgtype; AfxMessageBox(_T("没有找到初修片,将用原片替代!")); AryLoadExtImgpath.RemoveAll(); AryWithExtImgpath.RemoveAll(); AryOrderDirectory.RemoveAll(); if ( GetOrderImgpathEx(OImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; // 判断原片是否是选中的相片; if ( FindArray(&m_noarray, GetFileNameFromPath(str)) != -1) m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i)); } } } } #else CString path; path = g_path4 + "\\"; // 精修好的片; path += m_strOrderNum; path += "\\"; m_realpath = g_path4; CStringArray dirarray; CString str; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; m_photoarray1.Add(str); } } if (m_photoarray1.GetSize() == 0) { AfxMessageBox("没有找到精修片,将用初修片替代!"); path = g_path2 + "\\"; path += m_strOrderNum; path += "\\"; m_realpath = g_path2; CStringArray dirarray; CString str, temp; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1) continue; m_photoarray1.Add(str); } } } if (m_photoarray1.GetSize() == 0) { AfxMessageBox("没有找到初修片,将用原片替代!"); path = g_path1 + "\\"; path += m_strOrderNum; path += "\\"; m_realpath = g_path1; CStringArray dirarray; CString str, temp; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; CString strFileName = GetFileNameFromPath(str); if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1) continue; m_photoarray1.Add(str); } } } #endif // 相片张数; m_nphotos1 = m_photoarray1.GetSize(); // 相片容量大小; m_nspase1 = 0; for (i = 0; i < m_photoarray1.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray1.ElementAt(i), CFile::modeRead)) { m_nspase1 += fp.GetLength(); fp.Close(); } } m_nspase1temp = m_nspase1; } else { m_nphotos1 = m_photoarray1.GetSize(); m_nspase1 = m_nspase1temp; } } else { m_nphotos1 = 0; m_nspase1 = 0; } CString str; str.Format(_T("照片:%d 占用空间:%dM"), m_nphotos1, m_nspase1 / (1024 * 1024)); GetDlgItem(IDC_STATIC1)->SetWindowText(str); m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6; m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024); } void CNeroDlg::OnCheck2() // 顾客选中的相片(初修片) { UpdateData(); if (m_checkphoto2) { if (m_checkphoto5) m_checkphoto5 = 0; UpdateData(false); OnCheck5(); if (m_photoarray2.GetSize() == 0) { CString path; path = g_path2 + "\\"; path += m_strOrderNum; path += "\\"; CString str; if (m_noarray.GetSize() == 0) { AfxMessageBox("此单未选片!", MB_ICONINFORMATION); return; } int i = 0; for ( i = 0; i < m_noarray.GetSize(); i++) { str.Format("%s%s.jpg", path, m_noarray.ElementAt(i)); if (PathFileExists(str)) { m_photoarray2.Add(str); } } if (m_photoarray2.GetSize() == 0) { AfxMessageBox("警告:此单未导片!", MB_ICONSTOP); } m_nphotos2 = m_photoarray2.GetSize(); m_nspase2 = 0; for (i = 0; i < m_photoarray2.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray2.ElementAt(i), CFile::modeRead)) { m_nspase2 += fp.GetLength(); fp.Close(); } } m_nspase2temp = m_nspase2; } else { m_nphotos2 = m_photoarray2.GetSize(); m_nspase2 = m_nspase2temp; } } else { m_nphotos2 = 0; m_nspase2 = 0; } CString str; str.Format("照片:%d 占用空间:%dM", m_nphotos2, m_nspase2 / (1024 * 1024)); GetDlgItem(IDC_STATIC2)->SetWindowText(str); m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6; m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024); } void CNeroDlg::OnCheck3() // 顾客选中的相片(原片) { } /************************************************************************/ /* CheckBox:全部原片; */ /************************************************************************/ void CNeroDlg::OnCheck4() // 全部原片; { UpdateData(); if (m_checkphoto4) { if (m_photoarray4.GetSize() == 0) { INT i = 0; #ifdef USE_KERNEL_DLL CString str; INT nIndex = 0; DWORD dwReturnSize = 0; CStringArray AryLoadExtImgpath; CStringArray AryWithExtImgpath; CStringArray AryOrderDirectory; CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname); // 查找原片目录; if ( GetOrderImgpathEx(OImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; m_photoarray4.Add(AryLoadExtImgpath.ElementAt(i)); } } } #else CString path; path = g_path1 + "\\"; path += m_strOrderNum; path += "\\"; CStringArray dirarray; CString str; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; m_photoarray4.Add(str); } } #endif if (m_photoarray4.GetSize() == 0) { AfxMessageBox("警告:此单未导片!", MB_ICONSTOP); } m_nphotos4 = m_photoarray4.GetSize(); m_nspase4 = 0; for (i = 0; i < m_photoarray4.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray4.ElementAt(i), CFile::modeRead)) { m_nspase4 += fp.GetLength(); fp.Close(); } } m_nspase4temp = m_nspase4; } else { m_nphotos4 = m_photoarray4.GetSize(); m_nspase4 = m_nspase4temp; } } else { m_nphotos4 = 0; m_nspase4 = 0; } CString str; str.Format("照片:%d 占用空间:%dM", m_nphotos4, m_nspase4 / (1024 * 1024)); GetDlgItem(IDC_STATIC4)->SetWindowText(str); m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6; m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024); } /************************************************************************/ /* CheckBox:全部初修片; */ /************************************************************************/ void CNeroDlg::OnCheck5() // 全部初修片; { UpdateData(); if (m_checkphoto5) { if (m_photoarray5.GetSize() == 0) { INT i = 0; #ifdef USE_KERNEL_DLL CString str; INT nIndex = 0; DWORD dwReturnSize = 0; CStringArray AryLoadExtImgpath; CStringArray AryWithExtImgpath; CStringArray AryOrderDirectory; CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname); // 查找初修片目录; if ( GetOrderImgpathEx(EImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; m_photoarray5.Add(AryLoadExtImgpath.ElementAt(i)); } } } #else CString path; path = g_path2 + "\\"; path += m_strOrderNum; path += "\\"; CStringArray dirarray; CString str; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; m_photoarray5.Add(str); } } #endif if (m_photoarray5.GetSize() == 0) { AfxMessageBox("警告:此单未导片!", MB_ICONSTOP); } m_nphotos5 = m_photoarray5.GetSize(); m_nspase5 = 0; for (i = 0; i < m_photoarray5.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray5.ElementAt(i), CFile::modeRead)) { m_nspase5 += fp.GetLength(); fp.Close(); } } m_nspase5temp = m_nspase5; } else { m_nphotos5 = m_photoarray5.GetSize(); m_nspase5 = m_nspase5temp; } } else { m_nphotos5 = 0; m_nspase5 = 0; } CString str; str.Format("照片:%d 占用空间:%dM", m_nphotos5, m_nspase5 / (1024 * 1024)); GetDlgItem(IDC_STATIC5)->SetWindowText(str); m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6; m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024); } /************************************************************************/ /* CheckBox:全部设计片; */ /************************************************************************/ void CNeroDlg::OnCheck6() // 全部设计片; { UpdateData(); if (m_checkphoto6) { if (m_photoarray6.GetSize() == 0) { INT i = 0; #ifdef USE_KERNEL_DLL CString str; INT nIndex = 0; DWORD dwReturnSize = 0; CStringArray AryLoadExtImgpath; CStringArray AryWithExtImgpath; CStringArray AryOrderDirectory; CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname); // 查找初修片目录; if ( GetOrderImgpathEx(DImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) ) { INT nSize = AryLoadExtImgpath.GetSize(); for ( i = 0; i < nSize; i++ ) { str = AryLoadExtImgpath.ElementAt(i); nIndex = str.ReverseFind(_T('\\')); if ( nIndex != -1) { str = str.Mid(nIndex+1); if (str.ReverseFind(_T('.')) == -1) continue; if (str.GetAt(0) == 's')continue; if (str.GetAt(0) == 'm')continue; m_photoarray6.Add(AryLoadExtImgpath.ElementAt(i)); } } } #else CString path; path = g_path3 + "\\"; path += m_strOrderNum; path += "\\"; CStringArray dirarray; CString str; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(path), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); } } for ( i = 0; i < dirarray.GetSize(); i++) { using namespace helper_coffs; ffsco o; o.dirs(0); o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue; m_photoarray6.Add(str); } } #endif if (m_photoarray6.GetSize() == 0) { AfxMessageBox("警告:此单未导片!", MB_ICONSTOP); } m_nphotos6 = m_photoarray6.GetSize(); m_nspase6 = 0; for (i = 0; i < m_photoarray6.GetSize(); i++) { CFile fp; if (fp.Open(m_photoarray6.ElementAt(i), CFile::modeRead)) { m_nspase6 += fp.GetLength(); fp.Close(); } } m_nspase6temp = m_nspase6; } else { m_nphotos6 = m_photoarray6.GetSize(); m_nspase6 = m_nspase6temp; } } else { m_nphotos6 = 0; m_nspase6 = 0; } CString str; str.Format("照片:%d 占用空间:%dM", m_nphotos6, m_nspase6 / (1024 * 1024)); GetDlgItem(IDC_STATIC6)->SetWindowText(str); m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6; m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024); } //----------------------------------------------------------------- // remark by Jeff 2014-12-12 // 函数:GetNo // 描述:从str中解析出每个相片名,然后存入空的CStringArray中; // 参数: // str:选好的相片名串,如:"001,002,003" 后分隔符改为"|",结果应是"001|002|003" // array:空的数组,用来存放解析后的相片名; // 返回: // 注意:更换分隔符造成的问题,在该函数已解决; //----------------------------------------------------------------- void CNeroDlg::GetNo(CString str, CStringArray &array) { if (!str.IsEmpty()) { #ifdef USE_SEP_VEB int pos = str.Find(SEPS_VEB); #else int pos = str.Find(","); #endif while (pos != -1) { if (FindArray(&array, str.Left(pos)) == -1) array.Add(str.Left(pos)); str = str.Right(str.GetLength() - pos - 1); #ifdef USE_SEP_VEB pos = str.Find(SEPS_VEB); #else pos = str.Find(","); #endif } if (FindArray(&array, str) == -1) array.Add(str); } } extern bool SleepEx(DWORD dwMilliseconds); void CNeroDlg::OnOK() // 开始刻录; { #ifdef USE_KERNEL_DLL UpdateData(); // 刻录原片权限判断; if ( m_checkphoto4 ){ if ( !IsHasRights2new(54) ){ AfxMessageBox(_T("没有刻录原片权限,请联系管理员!")); return; } } // 刻录初修片权限判断; if ( m_checkphoto5 ){ if ( !IsHasRights2new(55) ){ AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!")); return; } } // 如果是压缩图片,需要创建temp目录,且g_mainpath需要有足够的空间; if ( m_bScale ){ // 删除DBServer.exe目录下的temp目录; DeleteDirectory(g_mainpath + _T("\\temp")); if ( !CheckDiskSpase() ) return; CreateDirectory(g_mainpath + _T("\\temp"), NULL); } if (m_nphotos == 0){ AfxMessageBox(_T("未选中照片!"), MB_ICONSTOP); return; } if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0){ AfxMessageBox(_T("光盘空间不足!"), MB_ICONSTOP); return; } GetDlgItem(IDOK)->SetWindowText(_T("刻录中, 请稍候...")); GetDlgItem(IDOK)->EnableWindow(0); if (NowDoingBurn){ OutputDebugString(_T("正在刻录!\n")); return; } m_Burn.m_strCustomerInfo = m_strCustomerInfo; if ( m_bFromDir ){// 由本机目录刻录,且相片从不压缩; CString strdir; GetDlgItemText(IDC_EDIT1, strdir); strdir.TrimRight(_T('\\')); // 获取该目录所有相片; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(strdir), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); NERO_ISO_ITEM *pItem = NULL; CString strName = strdir.Mid(strdir.ReverseFind(_T('\\')) + 1); if ( coo.size() ) { if( m_Burn.GetDiscItem() == NULL) { pItem = m_Burn.AddSiblingRootItem(strName, TRUE); } } CString strfile; CString strLast = _T(""); strName = strdir.Left(strdir.ReverseFind(_T('\\'))); for ( it = coo.begin(); it != coo.end(); it++ ) { // 获取文件目录; strfile = it->c_str(); // 去除根目录; strfile.Delete(0, strName.GetLength() + 1); strfile = strfile.Left(strfile.ReverseFind(_T('\\'))); if ( strfile == strLast ) { m_Burn.AddFile2SiblingItem(pItem, it->c_str()); } else { strLast = strfile; pItem = m_Burn.AddFile2Path(strfile, it->c_str()); } } } else{// 服务器的订单目录; INT nIndex = 0; NERO_ISO_ITEM* pItem = NULL; CString strLastName = _T(""); CString strFilePath = _T(""); if ( m_checkphoto1 ){// 如果勾选了精修,且相片从不压缩; if ( m_photoarray1.GetSize() ){ pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("精修"), TRUE); if ( pItem ) {// 成功添加根目录后,开始添加子文件; for ( INT i = 0; i < m_photoarray1.GetSize(); i++ ) { strFilePath = m_photoarray1.ElementAt(i); nIndex = strFilePath.Find(m_strOrderNum); if ( nIndex != -1 ) { strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患; nIndex = strFilePath.ReverseFind(_T('\\')); if ( nIndex != -1 ) {// 修片不进入,因无景点名; strFilePath = m_strOrderNum + _T("精修\\") + strFilePath.Left(nIndex); } else { strFilePath = m_strOrderNum + _T("精修\\"); } if ( strLastName == strFilePath ) { pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray1.ElementAt(i)); } else { pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray1.ElementAt(i)); strLastName = strFilePath; } } } } } } if ( m_checkphoto4 ){// 如果勾选了原片;(勾选压缩未选的片,作用) if ( m_photoarray4.GetSize() ){ pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("原片"), TRUE); if ( pItem ) {// 成功添加根目录后,开始添加子文件; for ( INT i = 0; i < m_photoarray4.GetSize(); i++ ) { strFilePath = m_photoarray4.ElementAt(i); nIndex = strFilePath.Find(m_strOrderNum); if ( nIndex != -1 ) { strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患; nIndex = strFilePath.ReverseFind(_T('\\')); if ( nIndex != -1 ) {// 修片不进入,因无景点名; strFilePath = m_strOrderNum + _T("原片\\") + strFilePath.Left(nIndex); } else { strFilePath = m_strOrderNum + _T("原片\\"); } if ( strLastName == strFilePath ) { pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray4.ElementAt(i)); } else { pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray4.ElementAt(i)); strLastName = strFilePath; } } } } } } if ( m_checkphoto5 ){// 如果勾选了初修;(勾选压缩未选的片,作用) if ( m_photoarray5.GetSize() ){ pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("初修"), TRUE); if ( pItem ) {// 成功添加根目录后,开始添加子文件; for ( INT i = 0; i < m_photoarray5.GetSize(); i++ ) { strFilePath = m_photoarray5.ElementAt(i); nIndex = strFilePath.Find(m_strOrderNum); if ( nIndex != -1 ) { strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患; nIndex = strFilePath.ReverseFind(_T('\\')); if ( nIndex != -1 ) {// 修片不进入,因无景点名; strFilePath = m_strOrderNum + _T("初修\\") + strFilePath.Left(nIndex); } else { strFilePath = m_strOrderNum + _T("初修\\"); } if ( strLastName == strFilePath ) { pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray5.ElementAt(i)); } else { pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray5.ElementAt(i)); strLastName = strFilePath; } } } } } } if ( m_checkphoto6 ){// 如果勾选了设计;(勾选压缩未选的片,不起作用) if ( m_photoarray6.GetSize() ){ pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("设计"), TRUE); if ( pItem ) {// 成功添加根目录后,开始添加子文件; for ( INT i = 0; i < m_photoarray6.GetSize(); i++ ) { strFilePath = m_photoarray6.ElementAt(i); nIndex = strFilePath.Find(m_strOrderNum); if ( nIndex != -1 ) { strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患; nIndex = strFilePath.ReverseFind(_T('\\')); if ( nIndex != -1 ) {// 修片不进入,因无景点名; strFilePath = m_strOrderNum + _T("设计\\") + strFilePath.Left(nIndex); } else { strFilePath = m_strOrderNum + _T("设计\\"); } if ( strLastName == strFilePath ) { pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray6.ElementAt(i)); } else { pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray6.ElementAt(i)); strLastName = strFilePath; } } } } } } if ( m_bScale ) {// 压缩未选的原片和初修片;若原片与初修有相同相片,以初修为主; // 获取m_photoarray5和m_photoarray4中公共未选的相片,压缩出来并重新添加; ImgCopyInterface *pCopyImg = NULL; g_pIMGProcess->QueryInterface(IID_ImgCopyInterface, (void**)&pCopyImg); if ( pCopyImg ) { pCopyImg->Release(); DWORD dwCopyPIX = 0; int pos=m_combo1.GetCurSel(); if(pos==0) { dwCopyPIX = SET_PIX(1200, 1600); } else if(pos==1) { dwCopyPIX = SET_PIX(768, 1024); } else if(pos==2) { dwCopyPIX = SET_PIX(600, 800); } else { dwCopyPIX = SET_PIX(480, 640); } INT i = 0; INT nSize = m_photoarray4.GetSize(); for ( i = 0; i < nSize; i++ ) { if ( FindArray(&m_noarray, GetFileNameFromPath(m_photoarray4.ElementAt(i))) == -1 ) { m_photoarray8.Add(m_photoarray4.ElementAt(i)); } } nSize = m_photoarray5.GetSize(); for ( i = 0; i < nSize; i++ ) { if ( FindArray(&m_noarray, GetFileNameFromPath(m_photoarray5.ElementAt(i))) == -1 ) { m_photoarray8.Add(m_photoarray5.ElementAt(i)); } } pCopyImg->CopyImg2Specifiedpath(m_photoarray8, g_mainpath + _T("\\temp\\"), _T(""), dwCopyPIX, FALSE, m_strOrderNum, FALSE); } CString strdir = g_mainpath + _T("\\temp"); // 获取该目录所有相片; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(strdir), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); if (coo.size()) { pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("未选的相片"), TRUE); if ( pItem ) { for ( it = coo.begin(); it != coo.end(); it++ ) { // 获取文件目录; strFilePath = it->c_str(); // 去除根目录; strFilePath.Delete(0, strdir.GetLength() + 1); strFilePath = m_strOrderNum + _T("未选的相片\\") + strFilePath.Left(strFilePath.ReverseFind(_T('\\'))); if ( strFilePath == strLastName ) { m_Burn.AddFile2SiblingItem(pItem, it->c_str()); } else { strLastName = strFilePath; pItem = m_Burn.AddFile2Path(strFilePath, it->c_str()); } } } } } } if (m_Burn.NeroAPIInit() == 0) { m_Burn.NeroWorkError = 1; m_Burn.RemoveRootItem(); return; } m_Burn.m_strCustomerInfo = m_strCustomerInfo; m_Burn.m_bDvd = m_bDvd; m_Burn.NeroAPIBurn(); m_Burn.RemoveRootItem(); NowDoingBurn = true; #else // 2015-07-23 刻录原片和初修片需要权限; if ( m_checkphoto4 ) { if ( !IsHasRights2new(54) ) { AfxMessageBox(_T("没有刻录原片权限,请联系管理员!")); return; } } if ( m_checkphoto5 ) { if ( !IsHasRights2new(55) ) { AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!")); return; } } ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录; ::CreateDirectory(g_mainpath + "\\temp", NULL); UpdateData(); if (m_bScale) { if (!CheckDiskSpase())return; } if (m_nphotos == 0) { AfxMessageBox("未选中照片!", MB_ICONSTOP); return; } if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0) { AfxMessageBox("光盘空间不足!", MB_ICONSTOP); return; } GetDlgItem(IDOK)->SetWindowText("刻录中, 请稍候..."); GetDlgItem(IDOK)->EnableWindow(0); if (NowDoingBurn) return; m_Burn.m_DirArray.RemoveAll(); m_Burn.m_DirRealNameArray.RemoveAll(); // CheckBox选中的相片类型与实际返回的相片路径的相片类型是否一致; CArraybIsSelectDirArray; int i = 0; CStringArray dirarray; using namespace helper_coffs; CStringArray srcarray; if (m_bFromDir) { CString strdir; GetDlgItemText(IDC_EDIT1, strdir); strdir.TrimRight('\\'); m_Burn.m_DirArray.Add(strdir); m_Burn.m_DirRealNameArray.Add(strdir); bIsSelectDirArray.Add(0); } else { if (m_checkphoto1) {// 精修片; if (m_realpath == g_path1 && m_checkphoto4) {// 没有找到精修,使用原片代替,将原片复制到temp目录中; SetDlgItemText(IDC_STATICTip, "照片复制中..."); m_Progress.SetRange(0, m_photoarray1.GetSize()); CString path = g_mainpath + "\\temp\\" + m_strOrderNum + "(精修)"; ::CreateDirectory(path, NULL); CString str; for ( i = 0; i < m_photoarray1.GetSize(); i++) { str = m_photoarray1.ElementAt(i); ::CopyFile(str, path + str.Right(str.GetLength() - str.ReverseFind('\\')), 0); m_Progress.SetPos(i); } // 将原片的temp目录添加到m_DirArray; m_Burn.m_DirArray.Add(path); m_Burn.m_DirRealNameArray.Add(path); bIsSelectDirArray.Add(0); } else { // 将精修片目录添加到m_DirArray; m_Burn.m_DirArray.Add(m_realpath + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(m_realpath + "\\" + m_strOrderNum + "(精修)"); // 如果选中的目录与精修相同,设置为FALSE; if (m_realpath == g_path4) bIsSelectDirArray.Add(0); else // 初修片或原片,但没有选取原片; bIsSelectDirArray.Add(1); } } if (m_checkphoto5) {// 初修片; m_Burn.m_DirArray.Add(g_path2 + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_strOrderNum + "(初修)"); bIsSelectDirArray.Add(0); } if (m_checkphoto4) {// 原片; m_Burn.m_DirArray.Add(g_path1 + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_strOrderNum + "(原片)"); bIsSelectDirArray.Add(0); } if (m_checkphoto6) {// 设计片; m_Burn.m_DirArray.Add(g_path3 + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(g_path3 + "\\" + m_strOrderNum + "(设计片)"); bIsSelectDirArray.Add(0); } } DWORD nNeedSpase = 0; if (m_bScale) {// 是否压缩相片后再刻录; SetDlgItemText(IDC_STATICTip, "照片裁切中..."); int pos = m_combo1.GetCurSel(); CStringArray needsaclearray; CStringArray dirarray; for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++) { // GenSPhoto:参数1:相片根目录,参数2:相片类型,参数3:返回的相片全路径;参数4:返回的相片新的保存路径; // GenSPhoto,将m_DirArray目录的相片放入needsaclearray中,再创建新的目录dirarray用来存放压缩后的相片。 GenSPhoto(m_Burn.m_DirArray.ElementAt(i), m_Burn.m_DirRealNameArray.ElementAt(i).Right(6), needsaclearray, dirarray); } m_Progress.SetRange(0, needsaclearray.GetSize()); for (i = 0; i < needsaclearray.GetSize(); i++) {// 压缩needscalearray相片到dirarray; CString str = needsaclearray.ElementAt(i); CString dir; dir = dirarray.ElementAt(i); Image *img = NULL; ::LoadImageFromBuf(&img, str); if (img->GetWidth()) { CRect rc(0, 0, 800, 800); if (pos == 0) { rc.right = 1600; rc.bottom = 1600; } else if (pos == 1) { rc.right = 1024; rc.bottom = 1024; } else if (pos == 2) { rc.right = 800; rc.bottom = 800; } else { rc.right = 640; rc.bottom = 640; } RectFitDes(img->GetWidth(), img->GetHeight(), rc); Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL); Graphics graphic(simg);//防止GetThumbnailImage影响质量 graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight()); delete img; CString savepath = dir + "\\" + ::GetFileNameFromPath(str) + ".jpg"; ::SaveImageToFile(simg, savepath); delete simg; CFile fp; if (fp.Open(savepath, CFile::modeRead)) { nNeedSpase += fp.GetLength(); fp.Close(); } else { str.Format("原片%s裁剪失败, 请查看此照片是否损坏。", savepath.Right(savepath.GetLength() - savepath.ReverseFind('\\') - 1)); AfxMessageBox(str); } } m_Progress.SetPos(i + 1); ::SleepEx(10); } if (::CheckFolderFileExist(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)")) {// 将压缩后的相片目录放到m_DirArray中; m_Burn.m_DirArray.Add(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)"); m_Burn.m_DirRealNameArray.Add(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)"); bIsSelectDirArray.Add(0); } } SetDlgItemText(IDC_STATICTip, "光盘刻录中..."); // dirarray的保存着最后全部相片的子目录; // 查找m_DirArray中的所有子目录并保存; CString str; CArraybIsSelectDirArray2; for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++) { ffsco o; o.dirs(1); o.find(LPCSTR(m_Burn.m_DirArray.ElementAt(i)), LPCSTR("*.*")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_dir(); for (it = coo.begin(); coo.end() != it; it++) { str = (*it).c_str(); str.TrimRight("\\"); if (FindArray(&dirarray, str) == -1) { dirarray.Add(str); // 所有子目录都设置成与根目录一样的属性; bIsSelectDirArray2.Add(bIsSelectDirArray.ElementAt(i)); } } } int addcount = 0; if (m_bFromDir == 0) { if (m_checkphoto2)addcount++; if (m_checkphoto3)addcount++; } if ((dirarray.GetSize() + addcount) == 0)return; // photosarray保存着每一个dirarray目录中的全部相片; CStringArray *photosarray = new CStringArray[dirarray.GetSize() + addcount]; for (i = 0; i < dirarray.GetSize(); i++) { GenSPhoto(dirarray.ElementAt(i), photosarray[i], nNeedSpase, bIsSelectDirArray2.ElementAt(i)); } if (m_bFromDir == 0) { int pos = dirarray.GetSize(); if (m_checkphoto2) { m_Burn.m_DirArray.Add(g_path2 + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_strOrderNum + "(初修)"); dirarray.Add(g_path2 + "\\" + m_strOrderNum); photosarray[pos].Copy(m_photoarray2); pos++; nNeedSpase += m_nspase1; } if (m_checkphoto3) { m_Burn.m_DirArray.Add(g_path1 + "\\" + m_strOrderNum); m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_strOrderNum + "(原片)"); dirarray.Add(g_path1 + "\\" + m_strOrderNum); photosarray[pos].Copy(m_photoarray3); nNeedSpase += m_nspase2; } } if (m_bScale) { nNeedSpase /= 1024 * 1024; if (nNeedSpase > 650 && m_bDvd == 0) { AfxMessageBox("光盘空间不足!", MB_ICONSTOP); delete[]photosarray; return; } } m_Burn.m_pDir = &dirarray; m_Burn.m_pPhotoArray = photosarray; if (m_Burn.NeroAPIInit() == 0) { m_Burn.NeroWorkError = 1; delete[]photosarray; return; } m_Burn.m_strCustomerInfo = m_strCustomerInfo; m_Burn.m_bDvd = m_bDvd; m_Burn.NeroAPIBurn(); NowDoingBurn = true; delete[]photosarray; ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录; if (m_Burn.NeroWorkError == 0) { CDialog::OnOK(); } else CDialog::OnCancel(); #endif } /************************************************************************/ /* CheckBox:缩小客人未选的相片; */ /************************************************************************/ void CNeroDlg::OnCheck7() { // TODO: Add your control notification handler code here UpdateData(); AfxGetApp()->WriteProfileInt(LYFZVERSION, "cutphoto", m_bScale); } BOOL CNeroDlg::CheckDiskSpase() { CString sDrive = g_mainpath.Left(2); DWORD dwTotalDiskSpace, dwFreeDiskSpace, dwUsedDiskSpace; ULARGE_INTEGER uiFreeBytesAvailableToCaller; ULARGE_INTEGER uiTotalNumberOfBytes; ULARGE_INTEGER uiTotalNumberOfFreeBytes; if (GetDiskFreeSpaceEx(sDrive, &uiFreeBytesAvailableToCaller, &uiTotalNumberOfBytes, &uiTotalNumberOfFreeBytes)) { dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024); dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20); dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace; } if (dwFreeDiskSpace > 600)return 1; AfxMessageBox("磁盘空间不足!", MB_ICONSTOP); return 0; } void CNeroDlg::OnCloseupCombo1() { // TODO: Add your control notification handler code here int pos = m_combo1.GetCurSel(); if (pos != -1) { AfxGetApp()->WriteProfileInt(LYFZVERSION, "cutphotosize", pos); } } /************************************************************************/ /* CheckBox:光盘类型cd; */ /************************************************************************/ void CNeroDlg::OnRadio1() { // TODO: Add your control notification handler code here OnRadio2(); } /************************************************************************/ /* CheckBox:光盘类型dvd; */ /************************************************************************/ void CNeroDlg::OnRadio2() { // TODO: Add your control notification handler code here UpdateData(); AfxGetApp()->WriteProfileInt(LYFZVERSION, "bDvd", m_bDvd); } void CNeroDlg::OnDestroy() { UpdateData(); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto1", m_checkphoto1); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto2", m_checkphoto2); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto3", m_checkphoto3); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto4", m_checkphoto4); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto5", m_checkphoto5); AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto6", m_checkphoto6); // TODO: Add your message handler code here CDialog::OnDestroy(); } //--------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------- /************************************************************************/ /* Jeff add 2014.09.03 */ /************************************************************************/ BOOL CopyFolder(CString strSrcPath, CString strDstPath) { // 创建目标文件夹; if (strSrcPath.Right(1) == "\\") { strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1); } if (strDstPath.Right(1) == "\\") { strDstPath = strDstPath.Left(strDstPath.GetLength() - 1); } CreateDirectory(strDstPath, NULL); CFileFind finder; // 打开指定的文件夹进行搜索; BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*"); while (bWorking) { // 从当前目录搜索文件; bWorking = finder.FindNextFile(); CString strFileName = finder.GetFileName(); CString strSrc = strSrcPath + "\\" + strFileName; CString strDst = strDstPath + "\\" + strFileName; // 判断搜索到的是不是"."和".."目录; if (!finder.IsDots()) { // 判断搜索到的目录是否是文件夹; if (finder.IsDirectory()) { // 如果是文件夹的话,进行递归; if (!CopyFolder(strSrc, strDst)) { return false; } } else { // 如果是文件,进行复制; if (!CopyFile(strSrc, strDst, FALSE)) { return false; } } } } return true; } void CNeroDlg::OnBnClickedExporttou() { #if 1 // 2015-07-23 刻录原片和初修片需要权限; if ( m_checkphoto4 ) { if ( !IsHasRights2new(54) ) { AfxMessageBox(_T("没有刻录原片权限,请联系管理员!")); return; } } if ( m_checkphoto5 ) { if ( !IsHasRights2new(55) ) { AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!")); return; } } #endif // 1.浏览文件U盘文件夹; EndofThread(); //CString sFolderPath; BROWSEINFO bi; char Buffer[MAX_PATH]; //初始化入口参数bi开始; bi.hwndOwner = NULL; bi.pidlRoot = NULL;//初始化制定的root目录很不容易, bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框; bi.lpszTitle = "修改接收路径"; //bi.ulFlags = BIF_BROWSEINCLUDEFILES;//包括文件; bi.ulFlags = BIF_EDITBOX | BIF_USENEWUI;//包括文件; bi.lpfn = NULL; bi.iImage = IDR_MAINFRAME; //初始化入口参数bi结束; LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框; if (pIDList) { if (!SHGetPathFromIDList(pIDList, Buffer)) return; //取得文件夹路径到Buffer里; //sFolderPath = Buffer;//将文件夹路径保存在一个CString对象里; m_strUFolder = Buffer; } else return; LPMALLOC lpMalloc; if (FAILED(SHGetMalloc(&lpMalloc))) return; lpMalloc->Free(pIDList); lpMalloc->Release(); // MessageBox(sFolderPath,"Title",MB_OK); // 1.2.获取盘符; BYTE bAlpha = m_strUFolder.GetAt(0); if (m_strUFolder.GetLength() != m_strUFolder.ReverseFind('\\')) { m_strUFolder += "\\"; } //printf("Jeff:保存目录 %s\n\n",m_strUFolder); // 2.获取U盘的大小等信息; CString strResult = _T(""); #if 1 __int64 iVolumeSize = 0, iVolumeFreeSize = 0; #else double iVolumeSize = 0.0, iVolumeFreeSize = 0.0; #endif if (!::IsCharAlpha((TCHAR)bAlpha)) { strResult = _T("驱动器参数无效!"); //return strResult; AfxMessageBox(strResult); return; } else { /**********获取驱动器名字、序列号和文件系统部分**********/ CString strRootPathName; strRootPathName.Format(_T("%c:\\"), bAlpha); LPCTSTR lpRootPathName = strRootPathName; LPTSTR lpVolumeNameBuffer = new char[_MAX_FNAME]; DWORD nVolumeNameSize = _MAX_FNAME; DWORD nVolumeSerialNumber = 0;//便于驱动器无效时做判断 ; DWORD nMaximumComponentLength; DWORD nFileSystemFlags; LPTSTR lpFileSystemNameBuffer = new char[20];//文件系统(NTFS,FAT)多大有定义好的宏吗 ; DWORD nFileSystemNameSize = 20; GetVolumeInformation( lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize, &nVolumeSerialNumber, &nMaximumComponentLength, &nFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize); /**********获取驱动器类型部分**********/ CString strDriveType; /**********获取驱动器总大小和剩余大小部分**********/ LPCTSTR lpDirectoryName = new char[2]; lpDirectoryName = (LPCTSTR)strRootPathName.Mid(0, 2); _ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes; GetDiskFreeSpaceEx(strRootPathName.Mid(0, 2), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes); #if 0 iVolumeSize = (double)TotalNumberOfBytes.QuadPart / 1024 / 1024; iVolumeFreeSize = (double)FreeBytesAvailable.QuadPart / 1024 / 1024; #else iVolumeSize = TotalNumberOfBytes.QuadPart; iVolumeFreeSize = FreeBytesAvailable.QuadPart; #endif } // 3.对比大小; DWORD64 dwTotalSize = m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6; if ((iVolumeFreeSize <= dwTotalSize) || (iVolumeFreeSize - dwTotalSize < 1024 * 10)) // 相差10K,认为容量不足; { AfxMessageBox("U盘容量不足!"); return; } // 4.拷贝文件 精修片 原片 初修片 设计片; // m_strOrderNum; // 订单号; CString strOrderFolder = _T(""); // 设置进度条; DWORD nTotalFiles = m_photoarray1.GetSize() + m_photoarray6.GetSize() + m_photoarray5.GetSize() + m_photoarray4.GetSize(); m_Progress.SetRange(0, nTotalFiles); // 5.由线程处理U盘的拷贝工作; StartThread(); GetDlgItem(Btn_ExportToU)->EnableWindow(FALSE); } DWORD WINAPI CNeroDlg::ExportImageThread(LPVOID lpParam) { CNeroDlg *pExportImageImpl = (CNeroDlg*)lpParam; int nIndexOfProcess = 0; CString strImageName = _T(""); CString strOrderFolder = _T(""); strOrderFolder.Format("%s%s\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); if (pExportImageImpl->m_bScale) { int nX = 0, nY = 0; int nPos = pExportImageImpl->m_combo1.GetCurSel(); if (nPos == 0) { nY = 1200; nX = 1600; } else if (nPos == 1) { nY = 768; nX = 1024; } else if (nPos = 2) { nY = 600; nX = 800; } else if (nPos == 3) { nY = 480; nX = 640; } //printf("Jeff:%s,%s\n\n",pExportImageImpl->m_strUFolder,pExportImageImpl->m_strOrderNum); if (pExportImageImpl->m_checkphoto1) // 精修目录; { strOrderFolder.Format("%s%s\\选好的片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); //printf("Jeff:1.%s\n\n",strOrderFolder); int nSize = pExportImageImpl->m_photoarray1.GetSize();//printf("Jeff:1.%d\n\n",nSize); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1)); //printf("Jeff:1.%s\n\n",strImageName); ToCompressImage(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, nX, nY); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto6) // 设计目录; { strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); int nSize = pExportImageImpl->m_photoarray6.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1)); //printf("Jeff:6.%s,%s\n\n",pExportImageImpl->m_photoarray1.ElementAt(i),strImageName); ToCompressImage(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, nX, nY); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto5) // 初修目录; { strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); //printf("Jeff:5.%s\n\n",strOrderFolder); int nSize = pExportImageImpl->m_photoarray5.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1)); ToCompressImage(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, nX, nY); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto4) // 原片目录; { strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); //printf("Jeff:4.%s\n\n",strOrderFolder); int nSize = pExportImageImpl->m_photoarray4.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1)); ToCompressImage(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, nX, nY); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } } else { if (pExportImageImpl->m_checkphoto1) // 精修目录; { strOrderFolder.Format("%s%s\\选好的片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); int nSize = pExportImageImpl->m_photoarray1.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1)); ::CopyFile(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, 0); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto6) // 设计目录; { strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); int nSize = pExportImageImpl->m_photoarray6.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1)); ::CopyFile(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, 0); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto5) // 初修目录; { strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); int nSize = pExportImageImpl->m_photoarray5.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1)); ::CopyFile(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, 0); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } if (pExportImageImpl->m_checkphoto4) // 原片目录; { strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum); ::CreateDirectory(strOrderFolder, NULL); int nSize = pExportImageImpl->m_photoarray4.GetSize(); for (int i = 0; i < nSize; i++) { strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1)); ::CopyFile(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, 0); pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess); } } } Sleep(1000); AfxMessageBox("导出完毕!"); pExportImageImpl->GetDlgItem(Btn_ExportToU)->EnableWindow(TRUE); pExportImageImpl->m_Progress.SetRange(0, 0); //pExportImageImpl->m_Progress.SetPos(0); return 0; } int CNeroDlg::StartThread() { m_hCtrl = CreateEvent(NULL, TRUE, FALSE, NULL); // 无信号事件; if (m_hCtrl == NULL) { //LOG4C((LOG_NOTICE,"创建事件失败")); //PostMessage(g_hwnd,MSG_SHOWPROMPTING,0,0); return -1; } //_hThread = CreateThread(NULL,0,ThreadProc,this,CREATE_SUSPENDED,NULL); m_hThread = CreateThread(NULL, 0, ExportImageThread, this, 0, NULL); if (m_hThread == NULL) { //LOG4C((LOG_NOTICE,"创建线程失败")); return -1; } //m_bThreadRuning = FALSE; m_bThreadRuning = TRUE; return 0; } int CNeroDlg::EndofThread() { // 1.关闭线程------------------------;; if (m_hCtrl) { SetEvent(m_hCtrl); } if (m_hThread) { if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT) { CloseHandle(m_hThread); m_hThread = NULL; } } m_bThreadRuning = FALSE; CloseHandle(m_hCtrl); m_hCtrl = NULL; return 0; } void CNeroDlg::ToCompressImage(__in const TCHAR *pImageSource, __in const TCHAR *pImageDest, __in const int &nXPiexel, __in const int &nYPiexel) { //printf("Jeff:%s,%s,%d,%d\n\n",pImageSource,pImageDest,nXPiexel,nYPiexel); #if 1 Image *pImage = NULL; #else Bitmap *pImage = NULL; #endif // 1.从文件中以读的方式加载图片到Image中; CFile cf; if (cf.Open(pImageSource, CFile::modeRead)) { DWORD dwLength = cf.GetLength(); BYTE *pData = new BYTE[dwLength]; if (pData == NULL)// 创建内存失败; { //printf("Jeff:1.创建内存失败\n\n"); return; } cf.Read(pData, dwLength); cf.Close(); // 1.1.将文件数据加载到内存数据中; HGLOBAL taghMem = GlobalAlloc(GMEM_MOVEABLE, dwLength); if (taghMem == NULL) // 创建内存失败; { //printf("Jeff:2.创建内存失败\n\n"); return; } BYTE *pMem = (BYTE*)GlobalLock(taghMem); memcpy(pMem, pData, dwLength); // 1.2.创建二进制流对象; IStream *pStream; CreateStreamOnHGlobal(taghMem, TRUE, &pStream); #if 1 pImage = Gdiplus::Image::FromStream(pStream); #else pImage = Gdiplus::Bitmap::FromStream(pStream); #endif GlobalUnlock(taghMem); pStream->Release(); delete[]pData; } else { //printf("Jeff:打开文件失败\n\n"); } // 2.加载后…… if (pImage == NULL) // 加载失败; { //printf("Jeff:加载图片失败\n\n"); return; } // 2.1.当图片的像素大于要设定的像素时,进行处理; if (pImage->GetWidth() > nXPiexel || pImage->GetHeight() > nYPiexel) { CRect tagRect(0, 0, nXPiexel, nYPiexel); RectFitDes_01(pImage->GetWidth(), pImage->GetHeight(), tagRect); Image *RtImage = pImage->GetThumbnailImage(tagRect.Width(), tagRect.Height(), NULL, NULL); Graphics graphic(RtImage); // 防止GetThumbnailImage影响图片质量; delete pImage; SaveImageToFile(RtImage, pImageDest); delete RtImage; } else // 直接用原片,不压缩; { ::CopyFile(pImageSource, pImageDest, 0); } } void CNeroDlg::RectFitDes_01(__in const int &nWidth, __in const int &nHeight, __inout CRect &rc) { try { if (nWidth == 0 || nHeight == 0)return; // 图片长宽比例; float fscale = (float)nWidth / (float)nHeight; // 设备长宽比例; float rcscale = ((float)rc.Width()) / ((float)rc.Height()); int rcwid = rc.Width(); int rchei = rc.Height(); int dt = 0; // Jeff.如果设备长宽比例 < 图片长宽比例;(即相同长度下,高越大比例值越小,所以此时图片尺寸 与 显示设备的尺寸相比,要显得更长) if (rcscale < fscale) { // Jeff.remarks // 调整显示设备的大小,以使之能容纳图片尺寸;(即长宽比例上,要大于或等于图片的长宽比例) // 所以有两种方法使得 rcscale >= fscale 表达式成立: // ----------------------------------------------- // 方法1:显示设备宽加x值,计算出下面表达式x的值即可 // (rc.Width()+x) / rc.Height() >= width/height; // 方法2:显示设备高减x值,计算出下面表达式x的值即可 // (rc.Width()) / (rc.Height()-x) >= width/height; //------------------------------------------------ // 两种方法的最后表达式为: // x >= rc.Height() - rcWidth()*(height/width); // 即 x >= rc.Height() - rcWidth()/fscale; //------------------------------------------------ dt = (rcwid - rchei*fscale) / 2; rc.left += dt; rc.right -= dt; } else { dt = (rchei - rcwid / fscale) / 2; rc.top += dt; rc.bottom -= dt; } } catch (...) { } } void CNeroDlg::SaveImageToFile(__in Image *img, __in CString path) { try { if (img == NULL) { //printf("Jeff:img == NULL \n\n"); return; } CLSID encoderClsid; BSTR bstr = path.AllocSysString(); path.MakeLower(); if (path.Right(3) == "bmp") { GetEncoderClsid(L"image/bmp", &encoderClsid); img->Save(bstr, &encoderClsid, NULL); } else if (path.Right(3) == "png") { GetEncoderClsid(L"image/png", &encoderClsid); img->Save(bstr, &encoderClsid, NULL); } else// if(path.Right (3)=="jpg") { GetEncoderClsid(L"image/jpeg", &encoderClsid); EncoderParameters encoderParameters; ULONG quality; encoderParameters.Count = 1; encoderParameters.Parameter[0].Guid = EncoderQuality; encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong; encoderParameters.Parameter[0].NumberOfValues = 1; // Save the image as a JPEG with quality level 100. quality = 100; encoderParameters.Parameter[0].Value = &quality; img->Save(bstr, &encoderClsid, &encoderParameters); } SysFreeString(bstr); } catch (...) { } } int CNeroDlg::GetEncoderClsid(__in const WCHAR* format, __inout CLSID* pClsid) { UINT num = 0; // number of image encoders UINT size = 0; // size of the image encoder array in bytes ImageCodecInfo* pImageCodecInfo = NULL; GetImageEncodersSize(&num, &size); if (size == 0) return -1; // Failure pImageCodecInfo = (ImageCodecInfo*)(malloc(size)); if (pImageCodecInfo == NULL) return -1; // Failure GetImageEncoders(num, size, pImageCodecInfo); for (UINT j = 0; j < num; ++j) { if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0) { *pClsid = pImageCodecInfo[j].Clsid; free(pImageCodecInfo); return j; // Success } } free(pImageCodecInfo); return -1; // FailureFailure }