NeroDlg.cpp 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042
  1. // NeroDlg1.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "NeroDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. CNeroDlg* pDlg;
  12. CNeroDlg::CNeroDlg(CWnd* pParent /*=NULL*/) : CDialog(CNeroDlg::IDD, pParent)
  13. {
  14. m_bFromDir = 0;
  15. m_bDvd = 0;
  16. m_checkphoto1 = 1;
  17. m_checkphoto2 = FALSE;
  18. m_checkphoto3 = FALSE;
  19. m_checkphoto4 = FALSE;
  20. m_checkphoto5 = FALSE;
  21. m_checkphoto6 = FALSE;
  22. pDlg = this;
  23. NowDoingBurn = false;
  24. m_nphotos = 0;
  25. m_nspase = 0;
  26. m_nphotos1 = 0;
  27. m_nspase1 = 0;
  28. m_nphotos2 = 0;
  29. m_nspase2 = 0;
  30. m_nphotos3 = 0;
  31. m_nspase3 = 0;
  32. m_nphotos4 = 0;
  33. m_nspase4 = 0;
  34. m_nphotos5 = 0;
  35. m_nspase5 = 0;
  36. m_nphotos6 = 0;
  37. m_nspase6 = 0;
  38. CString version = _T("Version 1.0");
  39. m_bScale = AfxGetApp()->GetProfileInt(version, "cutphoto", 1);
  40. m_bDvd = AfxGetApp()->GetProfileInt(version, "bDvd", 0);
  41. m_checkphoto1 = AfxGetApp()->GetProfileInt(version, "m_checkphoto1", 1);
  42. m_checkphoto2 = 0;//AfxGetApp()->GetProfileInt (version, "m_checkphoto2", 0);
  43. m_checkphoto3 = 0;//AfxGetApp()->GetProfileInt (version, "m_checkphoto3", 0);
  44. m_checkphoto4 = AfxGetApp()->GetProfileInt(version, "m_checkphoto4", 0);
  45. m_checkphoto5 = AfxGetApp()->GetProfileInt(version, "m_checkphoto5", 0);
  46. m_checkphoto6 = AfxGetApp()->GetProfileInt(version, "m_checkphoto6", 0);
  47. }
  48. void CNeroDlg::DoDataExchange(CDataExchange* pDX)
  49. {
  50. CDialog::DoDataExchange(pDX);
  51. //{{AFX_DATA_MAP(CNeroDlg)
  52. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  53. DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
  54. DDX_Radio(pDX, IDC_RADIO3, m_bFromDir);
  55. DDX_Radio(pDX, IDC_RADIO1, m_bDvd);
  56. DDX_Check(pDX, IDC_CHECK1, m_checkphoto1);
  57. DDX_Check(pDX, IDC_CHECK2, m_checkphoto2);
  58. DDX_Check(pDX, IDC_CHECK3, m_checkphoto3);
  59. DDX_Check(pDX, IDC_CHECK4, m_checkphoto4);
  60. DDX_Check(pDX, IDC_CHECK5, m_checkphoto5);
  61. DDX_Check(pDX, IDC_CHECK6, m_checkphoto6);
  62. DDX_Check(pDX, IDC_CHECK7, m_bScale);
  63. //}}AFX_DATA_MAP
  64. }
  65. BEGIN_MESSAGE_MAP(CNeroDlg, CDialog)
  66. //{{AFX_MSG_MAP(CNeroDlg)
  67. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  68. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  69. ON_BN_CLICKED(IDC_BUTchoosedir, OnBUTchoosedir)
  70. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  71. ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
  72. ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
  73. ON_BN_CLICKED(IDC_CHECK4, OnCheck4)
  74. ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
  75. ON_BN_CLICKED(IDC_CHECK6, OnCheck6)
  76. ON_BN_CLICKED(IDC_CHECK7, OnCheck7)
  77. ON_CBN_CLOSEUP(IDC_COMBO1, OnCloseupCombo1)
  78. ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  79. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  80. ON_WM_DESTROY()
  81. //}}AFX_MSG_MAP
  82. ON_BN_CLICKED(Btn_ExportToU, OnBnClickedExporttou)
  83. END_MESSAGE_MAP()
  84. // 需要处理分隔符产生的问题;
  85. BOOL CNeroDlg::OnInitDialog()
  86. {
  87. CDialog::OnInitDialog();
  88. m_Progress.SetRange(0, 100);
  89. EnableCtrls();
  90. CString filter = "id='" + m_id + "'";
  91. g_sendhead.bsql = 0;
  92. g_sendhead.code[0] = 50; // dindansp,需要处理分隔符产生的问题;
  93. g_sendhead.tabcount = 1;
  94. g_pMainWnd->ProcessChatMessageRequest2(filter);
  95. if (g_bSendOK == 0)
  96. {
  97. return 1;
  98. }
  99. CArray<CStringArray, CStringArray>sparray;
  100. DataToArray(&sparray);
  101. CString str, spname;
  102. CStringArray spnamearray;
  103. for (int i = 0; i < sparray.GetSize(); i++)
  104. {
  105. str = sparray.ElementAt(i).ElementAt(6);
  106. spname = sparray.ElementAt(i).ElementAt(5);
  107. GetNo(str, m_noarray);
  108. }
  109. m_combo1.AddString("1200x1600");
  110. m_combo1.AddString("768x1024");
  111. m_combo1.AddString("600x800");
  112. m_combo1.AddString("480x640");
  113. CString version = _T("Version 1.0");
  114. int pos = AfxGetApp()->GetProfileInt(version, "cutphotosize", 2);
  115. m_combo1.SetCurSel(pos);
  116. if (m_checkphoto1)OnCheck1();
  117. if (m_checkphoto2)OnCheck2();
  118. if (m_checkphoto3)OnCheck3();
  119. if (m_checkphoto4)OnCheck4();
  120. if (m_checkphoto5)OnCheck5();
  121. if (m_checkphoto6)OnCheck6();
  122. CenterWindow();
  123. return TRUE;
  124. }
  125. bool NERO_CALLBACK_ATTR CNeroDlg::IdleCallback(void *pUserData)
  126. {
  127. static MSG msg;
  128. while (!::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
  129. {
  130. if (!AfxGetThread()->PumpMessage())
  131. {
  132. break;
  133. }
  134. }
  135. return false;
  136. }
  137. NeroUserDlgInOut NERO_CALLBACK_ATTR CNeroDlg::UserDialog(void *pUserData, NeroUserDlgInOut type, void *data)
  138. {
  139. switch (type)
  140. {
  141. case DLG_AUTO_INSERT:
  142. return DLG_RETURN_CONTINUE;
  143. break;
  144. case DLG_DISCONNECT_RESTART:
  145. return DLG_RETURN_ON_RESTART;
  146. break;
  147. case DLG_DISCONNECT:
  148. return DLG_RETURN_CONTINUE;
  149. break;
  150. case DLG_AUTO_INSERT_RESTART:
  151. return DLG_RETURN_EXIT;
  152. break;
  153. case DLG_RESTART:
  154. return DLG_RETURN_EXIT;
  155. break;
  156. case DLG_SETTINGS_RESTART:
  157. return DLG_RETURN_CONTINUE;
  158. break;
  159. case DLG_OVERBURN:
  160. return DLG_RETURN_TRUE;
  161. break;
  162. case DLG_AUDIO_PROBLEMS:
  163. return DLG_RETURN_EXIT;
  164. break;
  165. case DLG_FILESEL_IMAGE:
  166. {
  167. // create filter for image files
  168. // create a CFileDialog object.
  169. // usage : CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
  170. // DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL,
  171. // CWnd* pParentWnd = NULL );
  172. //
  173. // bOpenFileDialog = TRUE, create a File Open dialog
  174. // lpszDefExt = NULL, do not automatically append a file extension
  175. // dwFlags = OFN_OVERWRITEPROMPT, makes no sense during file open,
  176. // just in case we decide to use File Save later
  177. // szFilter = "Image Files (*.nrg)|*.nrg|All Files (*.*)|*.*||"
  178. // pParentWnd = ((CNeroFiddlesDlg*)pUserData), our current Dialog window is the parent
  179. // user canceled, do not proceed with the burn process
  180. return DLG_BURNIMAGE_CANCEL;
  181. }
  182. break;
  183. case DLG_WAITCD:
  184. {
  185. AfxMessageBox("光盘不为空或类型错误");
  186. return DLG_RETURN_EXIT;
  187. break;
  188. }
  189. default:
  190. break;
  191. }
  192. //
  193. return DLG_RETURN_EXIT;
  194. }
  195. BOOL NERO_CALLBACK_ATTR CNeroDlg::ProgressCallback(void *pUserData, DWORD dwProgressInPercent)
  196. {
  197. ((CNeroDlg*)pUserData)->m_Progress.SetPos(dwProgressInPercent);
  198. return true;
  199. }
  200. BOOL NERO_CALLBACK_ATTR CNeroDlg::AbortedCallback(void *pUserData)
  201. {
  202. return false;
  203. return true;
  204. }
  205. void NERO_CALLBACK_ATTR CNeroDlg::AddLogLine(void *pUserData, NERO_TEXT_TYPE type, const char *text)
  206. {
  207. //((CNeroMFCappDlg*)pUserData)->AppendString("Log line:" +(CString)*text);
  208. return;
  209. }
  210. void NERO_CALLBACK_ATTR CNeroDlg::SetPhaseCallback(void *pUserData, const char *text)
  211. {
  212. return;
  213. }
  214. CString GetFileNameFromPath(CString path)
  215. {
  216. path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
  217. path = path.Left(path.Find('.'));
  218. return path;
  219. }
  220. void CNeroDlg::GenSPhoto(CString dir, CStringArray &array, DWORD &nNeedSpase, BOOL bCheckNo)
  221. {
  222. using namespace helper_coffs;
  223. ffsco o;
  224. o.dirs(0);
  225. o.find(LPCSTR(dir), LPCSTR("*.*"));
  226. ffsco::typeT coo;
  227. ffsco::typeT::iterator it;
  228. coo = o.co_file();
  229. CString str;
  230. for (it = coo.begin(); coo.end() != it; it++)
  231. {
  232. str = (*it).c_str();
  233. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  234. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  235. if (str.Right(2) == "ok")continue;
  236. if (bCheckNo)
  237. {
  238. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  239. continue;
  240. }
  241. if (m_bScale)
  242. {
  243. if (str.Find("客户原片") != -1 || str.Find("\\修好的片") != -1)
  244. {
  245. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) != -1)
  246. {
  247. array.Add(str);
  248. CFile fp;
  249. fp.Open(str, CFile::modeRead);
  250. nNeedSpase += fp.GetLength();
  251. fp.Close();
  252. }
  253. }
  254. else
  255. {
  256. array.Add(str);
  257. CFile fp;
  258. fp.Open(str, CFile::modeRead);
  259. nNeedSpase += fp.GetLength();
  260. fp.Close();
  261. }
  262. }
  263. else
  264. array.Add(str);
  265. }
  266. }
  267. void CNeroDlg::GenSPhoto(CString dir, CString sType, CStringArray &array, CStringArray &dirarray)
  268. {
  269. using namespace helper_coffs;
  270. ffsco o;
  271. o.dirs(1);
  272. o.find(LPCSTR(dir), LPCSTR("*.*"));
  273. ffsco::typeT coo;
  274. ffsco::typeT::iterator it;
  275. coo = o.co_file();
  276. CString str;
  277. for (it = coo.begin(); coo.end() != it; it++)
  278. {
  279. str = (*it).c_str();
  280. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  281. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  282. if (str.Right(2) == "ok")continue;
  283. if (m_bScale && (sType == "(初修)" || sType == "(原片)"))
  284. {
  285. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  286. {
  287. ::CreateDirectory(g_mainpath + "\\temp", NULL);
  288. ::CreateDirectory(g_mainpath + "\\temp\\" + m_id + "(未选的照片)", NULL);
  289. CString dir;
  290. dir = g_mainpath + "\\temp\\" + m_id + "(未选的照片)\\" + sType;
  291. ::CreateDirectory(dir, NULL);
  292. array.Add(str);
  293. dirarray.Add(dir);
  294. /* Image *img=NULL; 没有找到
  295. ::LoadImageFromBuf (&img, str);
  296. if(img->GetWidth())
  297. {
  298. CRect rc(0,0,800,800);
  299. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  300. Image *simg= img->GetThumbnailImage(rc.Width (), rc.Height (), NULL, NULL);
  301. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  302. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  303. delete img;
  304. ::SaveImageToFile(simg, dir+"\\"+::GetFileNameFromPath (str)+".jpg");
  305. delete simg;
  306. }*/
  307. }
  308. }
  309. }
  310. }
  311. int GetChildCount(CString str, CStringArray &array)
  312. {
  313. CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  314. int count = array.GetSize();
  315. CString temp;
  316. for (int i = 0; i < array.GetSize(); i++)
  317. {
  318. if (array.ElementAt(i) == str)
  319. count--;
  320. else if (array.ElementAt(i).Find(str) == -1)
  321. count--;
  322. else
  323. {
  324. temp = array.ElementAt(i);
  325. temp = temp.Left(temp.ReverseFind('\\'));
  326. if (temp != str)
  327. count--;
  328. }
  329. }
  330. return count;
  331. }
  332. void CNeroDlg::OnCancel()
  333. {
  334. // TODO: Add extra cleanup here
  335. //printf("Jeff:EndofThread\n\n");
  336. EndofThread(); // Jeff add.
  337. if (NowDoingBurn) //如果正在工作 则不能取消
  338. {
  339. if (m_Burn.NeroBurnOK)
  340. {
  341. CDialog::OnOK();
  342. return;
  343. }
  344. if (m_Burn.NeroWorkError)
  345. {
  346. CDialog::OnCancel();
  347. return;
  348. }
  349. AfxMessageBox("已经开始刻录了,不能中断");
  350. return;
  351. }
  352. CDialog::OnCancel(); //否则取消
  353. }
  354. void CNeroDlg::DoBurnOrNot()
  355. {
  356. m_Burn.NeroAPIInit();
  357. m_Burn.NeroAPIBurn();
  358. }
  359. BOOL CNeroDlg::PreTranslateMessage(MSG* pMsg)
  360. {
  361. return CDialog::PreTranslateMessage(pMsg);
  362. }
  363. void CNeroDlg::EnableCtrls()
  364. {
  365. GetDlgItem(IDC_CHECK1)->EnableWindow(!m_bFromDir);
  366. GetDlgItem(IDC_CHECK2)->EnableWindow(!m_bFromDir);
  367. GetDlgItem(IDC_CHECK3)->EnableWindow(!m_bFromDir);
  368. GetDlgItem(IDC_CHECK4)->EnableWindow(!m_bFromDir);
  369. GetDlgItem(IDC_CHECK5)->EnableWindow(!m_bFromDir);
  370. GetDlgItem(IDC_CHECK6)->EnableWindow(!m_bFromDir);
  371. GetDlgItem(IDC_BUTchoosedir)->EnableWindow(m_bFromDir);
  372. }
  373. void CNeroDlg::OnRadio3()
  374. {
  375. UpdateData();
  376. EnableCtrls();
  377. }
  378. void CNeroDlg::OnRadio4()
  379. {
  380. OnRadio3();
  381. }
  382. void CNeroDlg::OnBUTchoosedir()
  383. {
  384. CString dir;
  385. GetSavePath(dir);
  386. dir.IsEmpty();
  387. GetDlgItem(IDC_EDIT1)->SetWindowText(dir);
  388. m_photoarray7.RemoveAll();
  389. CString path;
  390. path = dir;
  391. CStringArray dirarray;
  392. CString str;
  393. using namespace helper_coffs;
  394. ffsco o;
  395. o.dirs(1);
  396. o.find(LPCSTR(path), LPCSTR("*.*"));
  397. ffsco::typeT coo;
  398. ffsco::typeT::iterator it;
  399. coo = o.co_dir();
  400. for (it = coo.begin(); coo.end() != it; it++)
  401. {
  402. str = (*it).c_str();
  403. if (FindArray(&dirarray, str) == -1)
  404. {
  405. dirarray.Add(str);
  406. }
  407. }
  408. int i = 0;
  409. for ( i = 0; i < dirarray.GetSize(); i++)
  410. {
  411. using namespace helper_coffs;
  412. ffsco o;
  413. o.dirs(0);
  414. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  415. ffsco::typeT coo;
  416. ffsco::typeT::iterator it;
  417. coo = o.co_file();
  418. for (it = coo.begin(); coo.end() != it; it++)
  419. {
  420. str = (*it).c_str();
  421. m_photoarray7.Add(str);
  422. }
  423. }
  424. if (m_photoarray7.GetSize() == 0)
  425. {
  426. AfxMessageBox("警告:目录中无照片!", MB_ICONSTOP);
  427. }
  428. m_nphotos = m_photoarray7.GetSize();
  429. m_nspase = 0;
  430. for (i = 0; i < m_photoarray7.GetSize(); i++)
  431. {
  432. CFile fp;
  433. if (fp.Open(m_photoarray7.ElementAt(i), CFile::modeRead))
  434. {
  435. m_nspase += fp.GetLength();
  436. fp.Close();
  437. }
  438. }
  439. m_nspase /= (1024 * 1024);
  440. str.Format("照片:%d 占用空间:%dM", m_nphotos, m_nspase);
  441. GetDlgItem(IDC_STATIC7)->SetWindowText(str);
  442. }
  443. void CNeroDlg::OnCheck1()
  444. {
  445. //printf("Jeff:%s,%s,%s,%s,%s,%s,%s,\n\n",g_path1,g_path2,g_path3,g_path4,g_path5,g_path6,g_path7);
  446. int i = 0;
  447. UpdateData();
  448. if (m_checkphoto1)
  449. {
  450. if (m_photoarray1.GetSize() == 0)
  451. {
  452. CString path;
  453. path = g_path4 + "\\"; // 精修好的片;
  454. path += m_id;
  455. path += "\\";
  456. m_realpath = g_path4;
  457. CStringArray dirarray;
  458. CString str;
  459. using namespace helper_coffs;
  460. ffsco o;
  461. o.dirs(1);
  462. o.find(LPCSTR(path), LPCSTR("*.*"));
  463. ffsco::typeT coo;
  464. ffsco::typeT::iterator it;
  465. coo = o.co_dir();
  466. for (it = coo.begin(); coo.end() != it; it++)
  467. {
  468. str = (*it).c_str();
  469. if (FindArray(&dirarray, str) == -1)
  470. {
  471. dirarray.Add(str);
  472. }
  473. }
  474. for ( i = 0; i < dirarray.GetSize(); i++)
  475. {
  476. using namespace helper_coffs;
  477. ffsco o;
  478. o.dirs(0);
  479. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  480. ffsco::typeT coo;
  481. ffsco::typeT::iterator it;
  482. coo = o.co_file();
  483. for (it = coo.begin(); coo.end() != it; it++)
  484. {
  485. str = (*it).c_str();
  486. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  487. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  488. m_photoarray1.Add(str);
  489. }
  490. }
  491. if (m_photoarray1.GetSize() == 0)
  492. {
  493. AfxMessageBox("没有找到精修片,将用初修片替代!");
  494. path = g_path2 + "\\";
  495. path += m_id;
  496. path += "\\";
  497. m_realpath = g_path2;
  498. CStringArray dirarray;
  499. CString str, temp;
  500. using namespace helper_coffs;
  501. ffsco o;
  502. o.dirs(1);
  503. o.find(LPCSTR(path), LPCSTR("*.*"));
  504. ffsco::typeT coo;
  505. ffsco::typeT::iterator it;
  506. coo = o.co_dir();
  507. for (it = coo.begin(); coo.end() != it; it++)
  508. {
  509. str = (*it).c_str();
  510. if (FindArray(&dirarray, str) == -1)
  511. {
  512. dirarray.Add(str);
  513. }
  514. }
  515. for ( i = 0; i < dirarray.GetSize(); i++)
  516. {
  517. using namespace helper_coffs;
  518. ffsco o;
  519. o.dirs(0);
  520. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  521. ffsco::typeT coo;
  522. ffsco::typeT::iterator it;
  523. coo = o.co_file();
  524. for (it = coo.begin(); coo.end() != it; it++)
  525. {
  526. str = (*it).c_str();
  527. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  528. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  529. /* temp=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  530. temp=temp.Left (3);
  531. if(FindArray(&m_noarray, temp)==-1)
  532. continue;*/
  533. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  534. continue;
  535. m_photoarray1.Add(str);
  536. }
  537. }
  538. }
  539. if (m_photoarray1.GetSize() == 0)
  540. {
  541. AfxMessageBox("没有找到初修片,将用原片替代!");
  542. path = g_path1 + "\\";
  543. path += m_id;
  544. path += "\\";
  545. m_realpath = g_path1;
  546. CStringArray dirarray;
  547. CString str, temp;
  548. using namespace helper_coffs;
  549. ffsco o;
  550. o.dirs(1);
  551. o.find(LPCSTR(path), LPCSTR("*.*"));
  552. ffsco::typeT coo;
  553. ffsco::typeT::iterator it;
  554. coo = o.co_dir();
  555. for (it = coo.begin(); coo.end() != it; it++)
  556. {
  557. str = (*it).c_str();
  558. if (FindArray(&dirarray, str) == -1)
  559. {
  560. dirarray.Add(str);
  561. }
  562. }
  563. for ( i = 0; i < dirarray.GetSize(); i++)
  564. {
  565. using namespace helper_coffs;
  566. ffsco o;
  567. o.dirs(0);
  568. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  569. ffsco::typeT coo;
  570. ffsco::typeT::iterator it;
  571. coo = o.co_file();
  572. for (it = coo.begin(); coo.end() != it; it++)
  573. {
  574. str = (*it).c_str();
  575. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  576. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  577. /* temp=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  578. temp=temp.Left (3);
  579. if(FindArray(&m_noarray, temp)==-1)
  580. continue;*/
  581. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  582. continue;
  583. m_photoarray1.Add(str);
  584. }
  585. }
  586. }
  587. m_nphotos1 = m_photoarray1.GetSize();
  588. m_nspase1 = 0;
  589. for (i = 0; i < m_photoarray1.GetSize(); i++)
  590. {
  591. CFile fp;
  592. if (fp.Open(m_photoarray1.ElementAt(i), CFile::modeRead))
  593. {
  594. m_nspase1 += fp.GetLength();
  595. fp.Close();
  596. }
  597. }
  598. m_nspase1temp = m_nspase1;
  599. }
  600. else
  601. {
  602. m_nphotos1 = m_photoarray1.GetSize();
  603. m_nspase1 = m_nspase1temp;
  604. }
  605. }
  606. else
  607. {
  608. m_nphotos1 = 0;
  609. m_nspase1 = 0;
  610. }
  611. CString str;
  612. str.Format("照片:%d 占用空间:%dM", m_nphotos1, m_nspase1 / (1024 * 1024));
  613. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  614. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  615. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  616. }
  617. void CNeroDlg::OnCheck2()
  618. {
  619. int i = 0;
  620. UpdateData();
  621. if (m_checkphoto2)
  622. {
  623. if (m_checkphoto5)
  624. m_checkphoto5 = 0;
  625. UpdateData(false);
  626. OnCheck5();
  627. if (m_photoarray2.GetSize() == 0)
  628. {
  629. CString path;
  630. path = g_path2 + "\\";
  631. path += m_id;
  632. path += "\\";
  633. CString str;
  634. if (m_noarray.GetSize() == 0)
  635. {
  636. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  637. return;
  638. }
  639. for ( i = 0; i < m_noarray.GetSize(); i++)
  640. {
  641. str.Format("%s%s.jpg", path, m_noarray.ElementAt(i));
  642. if (PathFileExists(str))
  643. {
  644. m_photoarray2.Add(str);
  645. }
  646. }
  647. if (m_photoarray2.GetSize() == 0)
  648. {
  649. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  650. }
  651. m_nphotos2 = m_photoarray2.GetSize();
  652. m_nspase2 = 0;
  653. for (i = 0; i < m_photoarray2.GetSize(); i++)
  654. {
  655. CFile fp;
  656. if (fp.Open(m_photoarray2.ElementAt(i), CFile::modeRead))
  657. {
  658. m_nspase2 += fp.GetLength();
  659. fp.Close();
  660. }
  661. }
  662. m_nspase2temp = m_nspase2;
  663. }
  664. else
  665. {
  666. m_nphotos2 = m_photoarray2.GetSize();
  667. m_nspase2 = m_nspase2temp;
  668. }
  669. }
  670. else
  671. {
  672. m_nphotos2 = 0;
  673. m_nspase2 = 0;
  674. }
  675. CString str;
  676. str.Format("照片:%d 占用空间:%dM", m_nphotos2, m_nspase2 / (1024 * 1024));
  677. GetDlgItem(IDC_STATIC2)->SetWindowText(str);
  678. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  679. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  680. }
  681. void CNeroDlg::OnCheck3()
  682. {
  683. // TODO: Add your control notification handler code here
  684. /* UpdateData();
  685. if(m_checkphoto3)
  686. {
  687. if(m_checkphoto4)
  688. m_checkphoto4=0;
  689. UpdateData(false);
  690. OnCheck4();
  691. if(m_photoarray3.GetSize ()==0)
  692. {
  693. CString path;
  694. path=g_path1+"\\";
  695. path+=m_id;
  696. path +="\\";
  697. if(m_noarray.GetSize ()==0)
  698. {
  699. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  700. return;
  701. }
  702. CString str;
  703. for(int i=0; i<m_noarray.GetSize (); i++)
  704. {
  705. str.Format ("%s%s.jpg", path, m_noarray.ElementAt (i));
  706. if(::CheckFolderFileExist (str))
  707. {
  708. m_photoarray3.Add (str);
  709. }
  710. }
  711. if(m_photoarray3.GetSize ()==0)
  712. {
  713. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  714. }
  715. m_nphotos3=m_photoarray3.GetSize ();
  716. m_nspase3=0;
  717. for( i=0; i<m_photoarray3.GetSize (); i++)
  718. {
  719. CFile fp;
  720. if(fp.Open (m_photoarray3.ElementAt (i), CFile::modeRead))
  721. {
  722. m_nspase3+=fp.GetLength ();
  723. fp.Close ();
  724. }
  725. }
  726. m_nspase3temp=m_nspase3;
  727. }
  728. else
  729. {
  730. m_nphotos3=m_photoarray3.GetSize ();
  731. m_nspase3=m_nspase3temp;
  732. }
  733. }
  734. else
  735. {
  736. m_nphotos3=0;
  737. m_nspase3=0;
  738. }
  739. CString str;
  740. str.Format ("照片:%d 占用空间:%dM", m_nphotos3, m_nspase3/(1024*1024));
  741. GetDlgItem(IDC_STATIC3)->SetWindowText(str);
  742. m_nphotos=m_nphotos1+m_nphotos2+m_nphotos3+m_nphotos4+m_nphotos5+m_nphotos6;
  743. m_nspase=(m_nspase1+m_nspase2+m_nspase3+m_nspase4+m_nspase5+m_nspase6)/(1024*1024);
  744. */
  745. }
  746. void CNeroDlg::OnCheck4()
  747. {
  748. UpdateData();
  749. if (m_checkphoto4)
  750. {
  751. /* if(m_checkphoto3)
  752. m_checkphoto3=0;
  753. UpdateData(false);
  754. OnCheck3();*/
  755. if (m_photoarray4.GetSize() == 0)
  756. {
  757. CString path;
  758. path = g_path1 + "\\";
  759. path += m_id;
  760. path += "\\";
  761. CStringArray dirarray;
  762. CString str;
  763. using namespace helper_coffs;
  764. ffsco o;
  765. o.dirs(1);
  766. o.find(LPCSTR(path), LPCSTR("*.*"));
  767. ffsco::typeT coo;
  768. ffsco::typeT::iterator it;
  769. coo = o.co_dir();
  770. for (it = coo.begin(); coo.end() != it; it++)
  771. {
  772. str = (*it).c_str();
  773. if (FindArray(&dirarray, str) == -1)
  774. {
  775. dirarray.Add(str);
  776. }
  777. }
  778. int i = 0;
  779. for ( i = 0; i < dirarray.GetSize(); i++)
  780. {
  781. using namespace helper_coffs;
  782. ffsco o;
  783. o.dirs(0);
  784. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  785. ffsco::typeT coo;
  786. ffsco::typeT::iterator it;
  787. coo = o.co_file();
  788. for (it = coo.begin(); coo.end() != it; it++)
  789. {
  790. str = (*it).c_str();
  791. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  792. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  793. m_photoarray4.Add(str);
  794. }
  795. }
  796. if (m_photoarray4.GetSize() == 0)
  797. {
  798. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  799. }
  800. m_nphotos4 = m_photoarray4.GetSize();
  801. m_nspase4 = 0;
  802. for (i = 0; i < m_photoarray4.GetSize(); i++)
  803. {
  804. CFile fp;
  805. if (fp.Open(m_photoarray4.ElementAt(i), CFile::modeRead))
  806. {
  807. m_nspase4 += fp.GetLength();
  808. fp.Close();
  809. }
  810. }
  811. m_nspase4temp = m_nspase4;
  812. }
  813. else
  814. {
  815. m_nphotos4 = m_photoarray4.GetSize();
  816. m_nspase4 = m_nspase4temp;
  817. }
  818. }
  819. else
  820. {
  821. m_nphotos4 = 0;
  822. m_nspase4 = 0;
  823. }
  824. CString str;
  825. str.Format("照片:%d 占用空间:%dM", m_nphotos4, m_nspase4 / (1024 * 1024));
  826. GetDlgItem(IDC_STATIC4)->SetWindowText(str);
  827. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  828. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  829. }
  830. void CNeroDlg::OnCheck5()
  831. {
  832. UpdateData();
  833. if (m_checkphoto5)
  834. {
  835. if (m_checkphoto2)
  836. m_checkphoto2 = 0;
  837. UpdateData(false);
  838. OnCheck2();
  839. if (m_photoarray5.GetSize() == 0)
  840. {
  841. CString path;
  842. path = g_path2 + "\\";
  843. path += m_id;
  844. path += "\\";
  845. CStringArray dirarray;
  846. CString str;
  847. using namespace helper_coffs;
  848. ffsco o;
  849. o.dirs(1);
  850. o.find(LPCSTR(path), LPCSTR("*.*"));
  851. ffsco::typeT coo;
  852. ffsco::typeT::iterator it;
  853. coo = o.co_dir();
  854. for (it = coo.begin(); coo.end() != it; it++)
  855. {
  856. str = (*it).c_str();
  857. if (FindArray(&dirarray, str) == -1)
  858. {
  859. dirarray.Add(str);
  860. }
  861. }
  862. int i = 0;
  863. for ( i = 0; i < dirarray.GetSize(); i++)
  864. {
  865. using namespace helper_coffs;
  866. ffsco o;
  867. o.dirs(0);
  868. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  869. ffsco::typeT coo;
  870. ffsco::typeT::iterator it;
  871. coo = o.co_file();
  872. for (it = coo.begin(); coo.end() != it; it++)
  873. {
  874. str = (*it).c_str();
  875. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  876. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  877. m_photoarray5.Add(str);
  878. }
  879. }
  880. if (m_photoarray5.GetSize() == 0)
  881. {
  882. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  883. }
  884. m_nphotos5 = m_photoarray5.GetSize();
  885. m_nspase5 = 0;
  886. for (i = 0; i < m_photoarray5.GetSize(); i++)
  887. {
  888. CFile fp;
  889. if (fp.Open(m_photoarray5.ElementAt(i), CFile::modeRead))
  890. {
  891. m_nspase5 += fp.GetLength();
  892. fp.Close();
  893. }
  894. }
  895. m_nspase5temp = m_nspase5;
  896. }
  897. else
  898. {
  899. m_nphotos5 = m_photoarray5.GetSize();
  900. m_nspase5 = m_nspase5temp;
  901. }
  902. }
  903. else
  904. {
  905. m_nphotos5 = 0;
  906. m_nspase5 = 0;
  907. }
  908. CString str;
  909. str.Format("照片:%d 占用空间:%dM", m_nphotos5, m_nspase5 / (1024 * 1024));
  910. GetDlgItem(IDC_STATIC5)->SetWindowText(str);
  911. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  912. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  913. }
  914. void CNeroDlg::OnCheck6()
  915. {
  916. UpdateData();
  917. if (m_checkphoto6)
  918. {
  919. if (m_photoarray6.GetSize() == 0)
  920. {
  921. CString path;
  922. path = g_path3 + "\\";
  923. path += m_id;
  924. path += "\\";
  925. CStringArray dirarray;
  926. CString str;
  927. using namespace helper_coffs;
  928. ffsco o;
  929. o.dirs(1);
  930. o.find(LPCSTR(path), LPCSTR("*.*"));
  931. ffsco::typeT coo;
  932. ffsco::typeT::iterator it;
  933. coo = o.co_dir();
  934. for (it = coo.begin(); coo.end() != it; it++)
  935. {
  936. str = (*it).c_str();
  937. if (FindArray(&dirarray, str) == -1)
  938. {
  939. dirarray.Add(str);
  940. }
  941. }
  942. int i = 0;
  943. for ( i = 0; i < dirarray.GetSize(); i++)
  944. {
  945. using namespace helper_coffs;
  946. ffsco o;
  947. o.dirs(0);
  948. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  949. ffsco::typeT coo;
  950. ffsco::typeT::iterator it;
  951. coo = o.co_file();
  952. for (it = coo.begin(); coo.end() != it; it++)
  953. {
  954. str = (*it).c_str();
  955. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  956. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  957. m_photoarray6.Add(str);
  958. }
  959. }
  960. if (m_photoarray6.GetSize() == 0)
  961. {
  962. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  963. }
  964. m_nphotos6 = m_photoarray6.GetSize();
  965. m_nspase6 = 0;
  966. for (i = 0; i < m_photoarray6.GetSize(); i++)
  967. {
  968. CFile fp;
  969. if (fp.Open(m_photoarray6.ElementAt(i), CFile::modeRead))
  970. {
  971. m_nspase6 += fp.GetLength();
  972. fp.Close();
  973. }
  974. }
  975. m_nspase6temp = m_nspase6;
  976. }
  977. else
  978. {
  979. m_nphotos6 = m_photoarray6.GetSize();
  980. m_nspase6 = m_nspase6temp;
  981. }
  982. }
  983. else
  984. {
  985. m_nphotos6 = 0;
  986. m_nspase6 = 0;
  987. }
  988. CString str;
  989. str.Format("照片:%d 占用空间:%dM", m_nphotos6, m_nspase6 / (1024 * 1024));
  990. GetDlgItem(IDC_STATIC6)->SetWindowText(str);
  991. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  992. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  993. }
  994. //-----------------------------------------------------------------
  995. // remark by Jeff 2014-12-12
  996. // 函数:GetNo
  997. // 描述:从str中解析出每个相片名,然后存入空的CStringArray中;
  998. // 参数:
  999. // str:选好的相片名串,如:"001,002,003" 后分隔符改为"|",结果应是"001|002|003"
  1000. // array:空的数组,用来存放解析后的相片名;
  1001. // 返回:
  1002. // 注意:更换分隔符造成的问题,在该函数已解决;
  1003. //-----------------------------------------------------------------
  1004. void CNeroDlg::GetNo(CString str, CStringArray &array)
  1005. {
  1006. if (!str.IsEmpty())
  1007. {
  1008. int pos = str.Find(",");
  1009. while (pos != -1)
  1010. {
  1011. if (FindArray(&array, str.Left(pos)) == -1)
  1012. array.Add(str.Left(pos));
  1013. str = str.Right(str.GetLength() - pos - 1);
  1014. pos = str.Find(",");
  1015. }
  1016. if (FindArray(&array, str) == -1)
  1017. array.Add(str);
  1018. }
  1019. }
  1020. extern bool SleepEx(DWORD dwMilliseconds);
  1021. //extern void DeleteDirectory(CString strDir);
  1022. void CNeroDlg::OnOK()
  1023. {
  1024. int i = 0;
  1025. ::DeleteDirectory(g_mainpath + "\\temp");
  1026. ::CreateDirectory(g_mainpath + "\\temp", NULL);
  1027. UpdateData();
  1028. if (m_bScale)
  1029. {
  1030. if (!CheckDiskSpase())return;
  1031. }
  1032. if (m_nphotos == 0)
  1033. {
  1034. AfxMessageBox("未选中照片!", MB_ICONSTOP);
  1035. return;
  1036. }
  1037. if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0)
  1038. {
  1039. AfxMessageBox("光盘空间不足!", MB_ICONSTOP);
  1040. return;
  1041. }
  1042. m_Burn.m_DirArray.RemoveAll();
  1043. m_Burn.m_DirRealNameArray.RemoveAll();
  1044. CArray<BOOL, BOOL>bIsSelectDirArray;
  1045. GetDlgItem(IDOK)->SetWindowText("刻录中, 请稍候...");
  1046. GetDlgItem(IDOK)->EnableWindow(0);
  1047. if (NowDoingBurn)
  1048. return;
  1049. CStringArray dirarray;
  1050. using namespace helper_coffs;
  1051. CStringArray srcarray;
  1052. if (m_bFromDir)
  1053. {
  1054. CString str;
  1055. GetDlgItemText(IDC_EDIT1, str);
  1056. str.TrimRight('\\');
  1057. m_Burn.m_DirArray.Add(str);
  1058. m_Burn.m_DirRealNameArray.Add(str);
  1059. bIsSelectDirArray.Add(0);
  1060. }
  1061. else
  1062. {
  1063. if (m_checkphoto1)
  1064. {
  1065. if (m_realpath == g_path1 && m_checkphoto4)//没有精修片用原片代替,同时又要刻原片时, 把原片备份出来
  1066. {
  1067. SetDlgItemText(IDC_STATICTip, "照片复制中...");
  1068. m_Progress.SetRange(0, m_photoarray1.GetSize());
  1069. CString path = g_mainpath + "\\temp\\" + m_id + "(精修)";
  1070. ::CreateDirectory(path, NULL);
  1071. CString str;
  1072. for (int i = 0; i < m_photoarray1.GetSize(); i++)
  1073. {
  1074. str = m_photoarray1.ElementAt(i);
  1075. ::CopyFile(str, path + str.Right(str.GetLength() - str.ReverseFind('\\')), 0);
  1076. m_Progress.SetPos(i);
  1077. }
  1078. m_Burn.m_DirArray.Add(path);
  1079. m_Burn.m_DirRealNameArray.Add(path);
  1080. bIsSelectDirArray.Add(0);
  1081. }
  1082. else
  1083. {
  1084. m_Burn.m_DirArray.Add(m_realpath + "\\" + m_id);
  1085. m_Burn.m_DirRealNameArray.Add(m_realpath + "\\" + m_id + "(精修)");
  1086. if (m_realpath == g_path4)
  1087. bIsSelectDirArray.Add(0);
  1088. else
  1089. bIsSelectDirArray.Add(1);
  1090. }
  1091. }
  1092. if (m_checkphoto5)
  1093. {
  1094. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
  1095. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
  1096. bIsSelectDirArray.Add(0);
  1097. }
  1098. if (m_checkphoto4)
  1099. {
  1100. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
  1101. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
  1102. bIsSelectDirArray.Add(0);
  1103. }
  1104. if (m_checkphoto6)
  1105. {
  1106. m_Burn.m_DirArray.Add(g_path3 + "\\" + m_id);
  1107. m_Burn.m_DirRealNameArray.Add(g_path3 + "\\" + m_id + "(设计片)");
  1108. bIsSelectDirArray.Add(0);
  1109. }
  1110. }
  1111. DWORD nNeedSpase = 0;
  1112. if (m_bScale)
  1113. {
  1114. SetDlgItemText(IDC_STATICTip, "照片裁切中...");
  1115. int pos = m_combo1.GetCurSel();
  1116. CStringArray needsaclearray;
  1117. CStringArray dirarray;
  1118. for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1119. {
  1120. GenSPhoto(m_Burn.m_DirArray.ElementAt(i), m_Burn.m_DirRealNameArray.ElementAt(i).Right(6), needsaclearray, dirarray);
  1121. }
  1122. m_Progress.SetRange(0, needsaclearray.GetSize());
  1123. for (i = 0; i < needsaclearray.GetSize(); i++)
  1124. {
  1125. CString str = needsaclearray.ElementAt(i);
  1126. CString dir;
  1127. dir = dirarray.ElementAt(i);
  1128. Image *img = NULL;
  1129. ::LoadImageFromBuf(&img, str);
  1130. if (img->GetWidth())
  1131. {
  1132. CRect rc(0, 0, 800, 800);
  1133. if (pos == 0)
  1134. {
  1135. rc.right = 1600;
  1136. rc.bottom = 1600;
  1137. }
  1138. else if (pos == 1)
  1139. {
  1140. rc.right = 1024;
  1141. rc.bottom = 1024;
  1142. }
  1143. else if (pos == 2)
  1144. {
  1145. rc.right = 800;
  1146. rc.bottom = 800;
  1147. }
  1148. else
  1149. {
  1150. rc.right = 640;
  1151. rc.bottom = 640;
  1152. }
  1153. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  1154. Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
  1155. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  1156. graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight());
  1157. delete img;
  1158. CString savepath = dir + "\\" + ::GetFileNameFromPath(str) + ".jpg";
  1159. ::SaveImageToFile(simg, savepath);
  1160. delete simg;
  1161. CFile fp;
  1162. if (fp.Open(savepath, CFile::modeRead))
  1163. {
  1164. nNeedSpase += fp.GetLength();
  1165. fp.Close();
  1166. }
  1167. else
  1168. {
  1169. /* ::CopyFile (str, savepath, 0);
  1170. if(fp.Open (savepath, CFile::modeRead))
  1171. {
  1172. nNeedSpase+=fp.GetLength ();
  1173. fp.Close ();
  1174. }*/
  1175. str.Format("原片%s裁剪失败, 请查看此照片是否损坏。", savepath.Right(savepath.GetLength() - savepath.ReverseFind('\\') - 1));
  1176. AfxMessageBox(str);
  1177. }
  1178. }
  1179. m_Progress.SetPos(i + 1);
  1180. ::SleepEx(10);
  1181. }
  1182. if (::CheckFolderFileExist(g_mainpath + "\\temp\\" + m_id + "(未选的照片)"))
  1183. {
  1184. m_Burn.m_DirArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
  1185. m_Burn.m_DirRealNameArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
  1186. bIsSelectDirArray.Add(0);
  1187. }
  1188. }
  1189. SetDlgItemText(IDC_STATICTip, "光盘刻录中...");
  1190. CString str;
  1191. CArray<BOOL, BOOL>bIsSelectDirArray2;
  1192. for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1193. {
  1194. ffsco o;
  1195. o.dirs(1);
  1196. o.find(LPCSTR(m_Burn.m_DirArray.ElementAt(i)), LPCSTR("*.*"));
  1197. ffsco::typeT coo;
  1198. ffsco::typeT::iterator it;
  1199. coo = o.co_dir();
  1200. for (it = coo.begin(); coo.end() != it; it++)
  1201. {
  1202. str = (*it).c_str();
  1203. str.TrimRight("\\");
  1204. if (FindArray(&dirarray, str) == -1)
  1205. {
  1206. dirarray.Add(str);
  1207. bIsSelectDirArray2.Add(bIsSelectDirArray.ElementAt(i));
  1208. }
  1209. }
  1210. }
  1211. int addcount = 0;
  1212. if (m_bFromDir == 0)
  1213. {
  1214. if (m_checkphoto2)addcount++;
  1215. if (m_checkphoto3)addcount++;
  1216. }
  1217. if ((dirarray.GetSize() + addcount) == 0)return;
  1218. CStringArray *photosarray = new CStringArray[dirarray.GetSize() + addcount];
  1219. for (i = 0; i < dirarray.GetSize(); i++)
  1220. {
  1221. GenSPhoto(dirarray.ElementAt(i), photosarray[i], nNeedSpase, bIsSelectDirArray2.ElementAt(i));
  1222. }
  1223. if (m_bFromDir == 0)
  1224. {
  1225. int pos = dirarray.GetSize();
  1226. if (m_checkphoto2)
  1227. {
  1228. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
  1229. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
  1230. dirarray.Add(g_path2 + "\\" + m_id);
  1231. photosarray[pos].Copy(m_photoarray2);
  1232. pos++;
  1233. nNeedSpase += m_nspase1;
  1234. }
  1235. if (m_checkphoto3)
  1236. {
  1237. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
  1238. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
  1239. dirarray.Add(g_path1 + "\\" + m_id);
  1240. photosarray[pos].Copy(m_photoarray3);
  1241. nNeedSpase += m_nspase2;
  1242. }
  1243. }
  1244. if (m_bScale)
  1245. {
  1246. nNeedSpase /= 1024 * 1024;
  1247. if (nNeedSpase > 650 && m_bDvd == 0)
  1248. {
  1249. AfxMessageBox("光盘空间不足!", MB_ICONSTOP); delete[]photosarray;
  1250. return;
  1251. }
  1252. }
  1253. m_Burn.m_pDir = &dirarray;
  1254. m_Burn.m_pPhotoArray = photosarray;
  1255. if (m_Burn.NeroAPIInit() == 0)
  1256. {
  1257. m_Burn.NeroWorkError = 1;
  1258. delete[]photosarray;
  1259. return;
  1260. }
  1261. m_Burn.m_name = m_name;
  1262. m_Burn.m_bDvd = m_bDvd;
  1263. m_Burn.NeroAPIBurn();
  1264. NowDoingBurn = true;
  1265. delete[]photosarray;
  1266. ::DeleteDirectory(g_mainpath + "\\temp");
  1267. if (m_Burn.NeroWorkError == 0)
  1268. {
  1269. CDialog::OnOK();
  1270. }
  1271. else
  1272. CDialog::OnCancel();
  1273. }
  1274. void CNeroDlg::OnCheck7()
  1275. {
  1276. // TODO: Add your control notification handler code here
  1277. UpdateData();
  1278. CString version = _T("Version 1.0");
  1279. AfxGetApp()->WriteProfileInt(version, "cutphoto", m_bScale);
  1280. }
  1281. BOOL CNeroDlg::CheckDiskSpase()
  1282. {
  1283. CString sDrive = g_mainpath.Left(2);
  1284. DWORD dwTotalDiskSpace, dwFreeDiskSpace, dwUsedDiskSpace;
  1285. ULARGE_INTEGER uiFreeBytesAvailableToCaller;
  1286. ULARGE_INTEGER uiTotalNumberOfBytes;
  1287. ULARGE_INTEGER uiTotalNumberOfFreeBytes;
  1288. if (GetDiskFreeSpaceEx(sDrive, &uiFreeBytesAvailableToCaller,
  1289. &uiTotalNumberOfBytes,
  1290. &uiTotalNumberOfFreeBytes))
  1291. {
  1292. dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
  1293. dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
  1294. dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
  1295. }
  1296. if (dwFreeDiskSpace > 600)return 1;
  1297. AfxMessageBox("磁盘空间不足!", MB_ICONSTOP);
  1298. return 0;
  1299. }
  1300. void CNeroDlg::OnCloseupCombo1()
  1301. {
  1302. // TODO: Add your control notification handler code here
  1303. int pos = m_combo1.GetCurSel();
  1304. if (pos != -1)
  1305. {
  1306. CString version = _T("Version 1.0");
  1307. AfxGetApp()->WriteProfileInt(version, "cutphotosize", pos);
  1308. }
  1309. }
  1310. void CNeroDlg::OnRadio1()
  1311. {
  1312. // TODO: Add your control notification handler code here
  1313. OnRadio2();
  1314. }
  1315. void CNeroDlg::OnRadio2()
  1316. {
  1317. // TODO: Add your control notification handler code here
  1318. UpdateData();
  1319. CString version = _T("Version 1.0");
  1320. AfxGetApp()->WriteProfileInt(version, "bDvd", m_bDvd);
  1321. }
  1322. void CNeroDlg::OnDestroy()
  1323. {
  1324. UpdateData();
  1325. CString version = _T("Version 1.0");
  1326. AfxGetApp()->WriteProfileInt(version, "m_checkphoto1", m_checkphoto1);
  1327. AfxGetApp()->WriteProfileInt(version, "m_checkphoto2", m_checkphoto2);
  1328. AfxGetApp()->WriteProfileInt(version, "m_checkphoto3", m_checkphoto3);
  1329. AfxGetApp()->WriteProfileInt(version, "m_checkphoto4", m_checkphoto4);
  1330. AfxGetApp()->WriteProfileInt(version, "m_checkphoto5", m_checkphoto5);
  1331. AfxGetApp()->WriteProfileInt(version, "m_checkphoto6", m_checkphoto6);
  1332. // TODO: Add your message handler code here
  1333. CDialog::OnDestroy();
  1334. }
  1335. //---------------------------------------------------------------------------------------------------
  1336. //---------------------------------------------------------------------------------------------------
  1337. /************************************************************************/
  1338. /*
  1339. Jeff add 2014.09.03
  1340. */
  1341. /************************************************************************/
  1342. BOOL CopyFolder(CString strSrcPath, CString strDstPath)
  1343. {
  1344. // 创建目标文件夹;
  1345. if (strSrcPath.Right(1) == "\\")
  1346. {
  1347. strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
  1348. }
  1349. if (strDstPath.Right(1) == "\\")
  1350. {
  1351. strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
  1352. }
  1353. CreateDirectory(strDstPath, NULL);
  1354. CFileFind finder;
  1355. // 打开指定的文件夹进行搜索;
  1356. BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*");
  1357. while (bWorking)
  1358. {
  1359. // 从当前目录搜索文件;
  1360. bWorking = finder.FindNextFile();
  1361. CString strFileName = finder.GetFileName();
  1362. CString strSrc = strSrcPath + "\\" + strFileName;
  1363. CString strDst = strDstPath + "\\" + strFileName;
  1364. // 判断搜索到的是不是"."和".."目录;
  1365. if (!finder.IsDots())
  1366. {
  1367. // 判断搜索到的目录是否是文件夹;
  1368. if (finder.IsDirectory())
  1369. {
  1370. // 如果是文件夹的话,进行递归;
  1371. if (!CopyFolder(strSrc, strDst))
  1372. {
  1373. return false;
  1374. }
  1375. }
  1376. else
  1377. {
  1378. // 如果是文件,进行复制;
  1379. if (!CopyFile(strSrc, strDst, FALSE))
  1380. {
  1381. return false;
  1382. }
  1383. }
  1384. }
  1385. }
  1386. return true;
  1387. }
  1388. void CNeroDlg::OnBnClickedExporttou()
  1389. {
  1390. // 1.浏览文件U盘文件夹;
  1391. EndofThread();
  1392. //CString sFolderPath;
  1393. BROWSEINFO bi;
  1394. char Buffer[MAX_PATH];
  1395. //初始化入口参数bi开始;
  1396. bi.hwndOwner = NULL;
  1397. bi.pidlRoot = NULL;//初始化制定的root目录很不容易,
  1398. bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框;
  1399. bi.lpszTitle = "修改接收路径";
  1400. //bi.ulFlags = BIF_BROWSEINCLUDEFILES;//包括文件;
  1401. bi.ulFlags = BIF_EDITBOX | BIF_USENEWUI;//包括文件;
  1402. bi.lpfn = NULL;
  1403. bi.iImage = IDR_MAINFRAME;
  1404. //初始化入口参数bi结束;
  1405. LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框;
  1406. if (pIDList)
  1407. {
  1408. if (!SHGetPathFromIDList(pIDList, Buffer))
  1409. return;
  1410. //取得文件夹路径到Buffer里;
  1411. //sFolderPath = Buffer;//将文件夹路径保存在一个CString对象里;
  1412. m_strUFolder = Buffer;
  1413. }
  1414. else
  1415. return;
  1416. LPMALLOC lpMalloc;
  1417. if (FAILED(SHGetMalloc(&lpMalloc)))
  1418. return;
  1419. lpMalloc->Free(pIDList);
  1420. lpMalloc->Release();
  1421. // MessageBox(sFolderPath,"Title",MB_OK);
  1422. // 1.2.获取盘符;
  1423. BYTE bAlpha = m_strUFolder.GetAt(0);
  1424. if (m_strUFolder.GetLength() != m_strUFolder.ReverseFind('\\'))
  1425. {
  1426. m_strUFolder += "\\";
  1427. }
  1428. //printf("Jeff:保存目录 %s\n\n",m_strUFolder);
  1429. // 2.获取U盘的大小等信息;
  1430. CString strResult = _T("");
  1431. #if 1
  1432. __int64 iVolumeSize = 0, iVolumeFreeSize = 0;
  1433. #else
  1434. double iVolumeSize = 0.0, iVolumeFreeSize = 0.0;
  1435. #endif
  1436. if (!::IsCharAlpha((TCHAR)bAlpha))
  1437. {
  1438. strResult = _T("驱动器参数无效!");
  1439. //return strResult;
  1440. AfxMessageBox(strResult);
  1441. return;
  1442. }
  1443. else
  1444. {
  1445. /**********获取驱动器名字、序列号和文件系统部分**********/
  1446. CString strRootPathName;
  1447. strRootPathName.Format(_T("%c:\\"), bAlpha);
  1448. LPCTSTR lpRootPathName = strRootPathName;
  1449. LPTSTR lpVolumeNameBuffer = new char[_MAX_FNAME];
  1450. DWORD nVolumeNameSize = _MAX_FNAME;
  1451. DWORD nVolumeSerialNumber = 0;//便于驱动器无效时做判断 ;
  1452. DWORD nMaximumComponentLength;
  1453. DWORD nFileSystemFlags;
  1454. LPTSTR lpFileSystemNameBuffer = new char[20];//文件系统(NTFS,FAT)多大有定义好的宏吗 ;
  1455. DWORD nFileSystemNameSize = 20;
  1456. GetVolumeInformation(
  1457. lpRootPathName,
  1458. lpVolumeNameBuffer,
  1459. nVolumeNameSize,
  1460. &nVolumeSerialNumber,
  1461. &nMaximumComponentLength,
  1462. &nFileSystemFlags,
  1463. lpFileSystemNameBuffer,
  1464. nFileSystemNameSize);
  1465. /**********获取驱动器类型部分**********/
  1466. CString strDriveType;
  1467. /**********获取驱动器总大小和剩余大小部分**********/
  1468. LPCTSTR lpDirectoryName = new char[2];
  1469. lpDirectoryName = (LPCTSTR)strRootPathName.Mid(0, 2);
  1470. _ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
  1471. GetDiskFreeSpaceEx(strRootPathName.Mid(0, 2), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
  1472. #if 0
  1473. iVolumeSize = (double)TotalNumberOfBytes.QuadPart / 1024 / 1024;
  1474. iVolumeFreeSize = (double)FreeBytesAvailable.QuadPart / 1024 / 1024;
  1475. #else
  1476. iVolumeSize = TotalNumberOfBytes.QuadPart;
  1477. iVolumeFreeSize = FreeBytesAvailable.QuadPart;
  1478. #endif
  1479. }
  1480. // 3.对比大小;
  1481. DWORD64 dwTotalSize = m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6;
  1482. if ((iVolumeFreeSize <= dwTotalSize) || (iVolumeFreeSize - dwTotalSize < 1024 * 10)) // 相差10K,认为容量不足;
  1483. {
  1484. AfxMessageBox("U盘容量不足!");
  1485. return;
  1486. }
  1487. // 4.拷贝文件 精修片 原片 初修片 设计片;
  1488. // m_id; // 订单号;
  1489. CString strOrderFolder = _T("");
  1490. // 设置进度条;
  1491. DWORD nTotalFiles = m_photoarray1.GetSize() + m_photoarray6.GetSize() + m_photoarray5.GetSize() + m_photoarray4.GetSize();
  1492. m_Progress.SetRange(0, nTotalFiles);
  1493. // 5.由线程处理U盘的拷贝工作;
  1494. StartThread();
  1495. GetDlgItem(Btn_ExportToU)->EnableWindow(FALSE);
  1496. }
  1497. DWORD WINAPI CNeroDlg::ExportImageThread(LPVOID lpParam)
  1498. {
  1499. CNeroDlg *pExportImageImpl = (CNeroDlg*)lpParam;
  1500. int nIndexOfProcess = 0;
  1501. CString strImageName = _T("");
  1502. CString strOrderFolder = _T("");
  1503. strOrderFolder.Format("%s%s\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1504. ::CreateDirectory(strOrderFolder, NULL);
  1505. if (pExportImageImpl->m_bScale)
  1506. {
  1507. int nX = 0, nY = 0;
  1508. int nPos = pExportImageImpl->m_combo1.GetCurSel();
  1509. if (nPos == 0)
  1510. {
  1511. nY = 1200;
  1512. nX = 1600;
  1513. }
  1514. else if (nPos == 1)
  1515. {
  1516. nY = 768;
  1517. nX = 1024;
  1518. }
  1519. else if (nPos = 2)
  1520. {
  1521. nY = 600;
  1522. nX = 800;
  1523. }
  1524. else if (nPos == 3)
  1525. {
  1526. nY = 480;
  1527. nX = 640;
  1528. }
  1529. //printf("Jeff:%s,%s\n\n",pExportImageImpl->m_strUFolder,pExportImageImpl->m_id);
  1530. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  1531. {
  1532. strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1533. ::CreateDirectory(strOrderFolder, NULL);
  1534. //printf("Jeff:1.%s\n\n",strOrderFolder);
  1535. int nSize = pExportImageImpl->m_photoarray1.GetSize();//printf("Jeff:1.%d\n\n",nSize);
  1536. for (int i = 0; i < nSize; i++)
  1537. {
  1538. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  1539. //printf("Jeff:1.%s\n\n",strImageName);
  1540. ToCompressImage(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, nX, nY);
  1541. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1542. }
  1543. }
  1544. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  1545. {
  1546. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1547. ::CreateDirectory(strOrderFolder, NULL);
  1548. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  1549. for (int i = 0; i < nSize; i++)
  1550. {
  1551. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  1552. //printf("Jeff:6.%s,%s\n\n",pExportImageImpl->m_photoarray1.ElementAt(i),strImageName);
  1553. ToCompressImage(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, nX, nY);
  1554. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1555. }
  1556. }
  1557. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  1558. {
  1559. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1560. ::CreateDirectory(strOrderFolder, NULL);
  1561. //printf("Jeff:5.%s\n\n",strOrderFolder);
  1562. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  1563. for (int i = 0; i < nSize; i++)
  1564. {
  1565. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  1566. ToCompressImage(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, nX, nY);
  1567. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1568. }
  1569. }
  1570. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  1571. {
  1572. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1573. ::CreateDirectory(strOrderFolder, NULL);
  1574. //printf("Jeff:4.%s\n\n",strOrderFolder);
  1575. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  1576. for (int i = 0; i < nSize; i++)
  1577. {
  1578. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  1579. ToCompressImage(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, nX, nY);
  1580. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1581. }
  1582. }
  1583. }
  1584. else
  1585. {
  1586. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  1587. {
  1588. strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1589. ::CreateDirectory(strOrderFolder, NULL);
  1590. int nSize = pExportImageImpl->m_photoarray1.GetSize();
  1591. for (int i = 0; i < nSize; i++)
  1592. {
  1593. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  1594. ::CopyFile(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, 0);
  1595. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1596. }
  1597. }
  1598. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  1599. {
  1600. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1601. ::CreateDirectory(strOrderFolder, NULL);
  1602. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  1603. for (int i = 0; i < nSize; i++)
  1604. {
  1605. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  1606. ::CopyFile(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, 0);
  1607. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1608. }
  1609. }
  1610. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  1611. {
  1612. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1613. ::CreateDirectory(strOrderFolder, NULL);
  1614. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  1615. for (int i = 0; i < nSize; i++)
  1616. {
  1617. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  1618. ::CopyFile(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, 0);
  1619. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1620. }
  1621. }
  1622. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  1623. {
  1624. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1625. ::CreateDirectory(strOrderFolder, NULL);
  1626. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  1627. for (int i = 0; i < nSize; i++)
  1628. {
  1629. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  1630. ::CopyFile(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, 0);
  1631. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1632. }
  1633. }
  1634. }
  1635. Sleep(1000);
  1636. AfxMessageBox("导出完毕!");
  1637. pExportImageImpl->GetDlgItem(Btn_ExportToU)->EnableWindow(TRUE);
  1638. pExportImageImpl->m_Progress.SetRange(0, 0);
  1639. //pExportImageImpl->m_Progress.SetPos(0);
  1640. return 0;
  1641. }
  1642. int CNeroDlg::StartThread()
  1643. {
  1644. m_hCtrl = CreateEvent(NULL, TRUE, FALSE, NULL); // 无信号事件;
  1645. if (m_hCtrl == NULL)
  1646. {
  1647. //LOG4C((LOG_NOTICE,"创建事件失败"));
  1648. //PostMessage(g_hwnd,MSG_SHOWPROMPTING,0,0);
  1649. return -1;
  1650. }
  1651. //_hThread = CreateThread(NULL,0,ThreadProc,this,CREATE_SUSPENDED,NULL);
  1652. m_hThread = CreateThread(NULL, 0, ExportImageThread, this, 0, NULL);
  1653. if (m_hThread == NULL)
  1654. {
  1655. //LOG4C((LOG_NOTICE,"创建线程失败"));
  1656. return -1;
  1657. }
  1658. //m_bThreadRuning = FALSE;
  1659. m_bThreadRuning = TRUE;
  1660. return 0;
  1661. }
  1662. int CNeroDlg::EndofThread()
  1663. {
  1664. // 1.关闭线程------------------------;;
  1665. if (m_hCtrl)
  1666. {
  1667. SetEvent(m_hCtrl);
  1668. }
  1669. if (m_hThread)
  1670. {
  1671. if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT)
  1672. {
  1673. CloseHandle(m_hThread);
  1674. m_hThread = NULL;
  1675. }
  1676. }
  1677. m_bThreadRuning = FALSE;
  1678. CloseHandle(m_hCtrl);
  1679. m_hCtrl = NULL;
  1680. return 0;
  1681. }
  1682. void CNeroDlg::ToCompressImage( const TCHAR *pImageSource, const TCHAR *pImageDest, const int &nXPiexel, const int &nYPiexel)
  1683. {
  1684. //printf("Jeff:%s,%s,%d,%d\n\n",pImageSource,pImageDest,nXPiexel,nYPiexel);
  1685. #if 1
  1686. Image *pImage = NULL;
  1687. #else
  1688. Bitmap *pImage = NULL;
  1689. #endif
  1690. // 1.从文件中以读的方式加载图片到Image中;
  1691. CFile cf;
  1692. if (cf.Open(pImageSource, CFile::modeRead))
  1693. {
  1694. DWORD dwLength = cf.GetLength();
  1695. BYTE *pData = new BYTE[dwLength];
  1696. if (pData == NULL)// 创建内存失败;
  1697. {
  1698. //printf("Jeff:1.创建内存失败\n\n");
  1699. return;
  1700. }
  1701. cf.Read(pData, dwLength);
  1702. cf.Close();
  1703. // 1.1.将文件数据加载到内存数据中;
  1704. HGLOBAL taghMem = GlobalAlloc(GMEM_MOVEABLE, dwLength);
  1705. if (taghMem == NULL) // 创建内存失败;
  1706. {
  1707. //printf("Jeff:2.创建内存失败\n\n");
  1708. return;
  1709. }
  1710. BYTE *pMem = (BYTE*)GlobalLock(taghMem);
  1711. memcpy(pMem, pData, dwLength);
  1712. // 1.2.创建二进制流对象;
  1713. IStream *pStream;
  1714. CreateStreamOnHGlobal(taghMem, TRUE, &pStream);
  1715. #if 1
  1716. pImage = Gdiplus::Image::FromStream(pStream);
  1717. #else
  1718. pImage = Gdiplus::Bitmap::FromStream(pStream);
  1719. #endif
  1720. GlobalUnlock(taghMem);
  1721. pStream->Release();
  1722. delete[]pData;
  1723. }
  1724. else
  1725. {
  1726. //printf("Jeff:打开文件失败\n\n");
  1727. }
  1728. // 2.加载后……
  1729. if (pImage == NULL) // 加载失败;
  1730. {
  1731. //printf("Jeff:加载图片失败\n\n");
  1732. return;
  1733. }
  1734. // 2.1.当图片的像素大于要设定的像素时,进行处理;
  1735. if (pImage->GetWidth() > nXPiexel || pImage->GetHeight() > nYPiexel)
  1736. {
  1737. CRect tagRect(0, 0, nXPiexel, nYPiexel);
  1738. RectFitDes_01(pImage->GetWidth(), pImage->GetHeight(), tagRect);
  1739. Image *RtImage = pImage->GetThumbnailImage(tagRect.Width(), tagRect.Height(), NULL, NULL);
  1740. Graphics graphic(RtImage); // 防止GetThumbnailImage影响图片质量;
  1741. delete pImage;
  1742. SaveImageToFile(RtImage, pImageDest);
  1743. delete RtImage;
  1744. }
  1745. else // 直接用原片,不压缩;
  1746. {
  1747. ::CopyFile(pImageSource, pImageDest, 0);
  1748. }
  1749. }
  1750. void CNeroDlg::RectFitDes_01( const int &nWidth, const int &nHeight, CRect &rc)
  1751. {
  1752. try
  1753. {
  1754. if (nWidth == 0 || nHeight == 0)return;
  1755. // 图片长宽比例;
  1756. float fscale = (float)nWidth / (float)nHeight;
  1757. // 设备长宽比例;
  1758. float rcscale = ((float)rc.Width()) / ((float)rc.Height());
  1759. int rcwid = rc.Width();
  1760. int rchei = rc.Height();
  1761. int dt = 0;
  1762. // Jeff.如果设备长宽比例 < 图片长宽比例;(即相同长度下,高越大比例值越小,所以此时图片尺寸 与 显示设备的尺寸相比,要显得更长)
  1763. if (rcscale < fscale)
  1764. {
  1765. // Jeff.remarks
  1766. // 调整显示设备的大小,以使之能容纳图片尺寸;(即长宽比例上,要大于或等于图片的长宽比例)
  1767. // 所以有两种方法使得 rcscale >= fscale 表达式成立:
  1768. // -----------------------------------------------
  1769. // 方法1:显示设备宽加x值,计算出下面表达式x的值即可
  1770. // (rc.Width()+x) / rc.Height() >= width/height;
  1771. // 方法2:显示设备高减x值,计算出下面表达式x的值即可
  1772. // (rc.Width()) / (rc.Height()-x) >= width/height;
  1773. //------------------------------------------------
  1774. // 两种方法的最后表达式为:
  1775. // x >= rc.Height() - rcWidth()*(height/width);
  1776. // 即 x >= rc.Height() - rcWidth()/fscale;
  1777. //------------------------------------------------
  1778. dt = (rcwid - rchei*fscale) / 2;
  1779. rc.left += dt;
  1780. rc.right -= dt;
  1781. }
  1782. else
  1783. {
  1784. dt = (rchei - rcwid / fscale) / 2;
  1785. rc.top += dt;
  1786. rc.bottom -= dt;
  1787. }
  1788. }
  1789. catch (...)
  1790. {
  1791. }
  1792. }
  1793. void CNeroDlg::SaveImageToFile( Image *img, CString path)
  1794. {
  1795. try
  1796. {
  1797. if (img == NULL)
  1798. {
  1799. //printf("Jeff:img == NULL \n\n");
  1800. return;
  1801. }
  1802. CLSID encoderClsid;
  1803. BSTR bstr = path.AllocSysString();
  1804. path.MakeLower();
  1805. if (path.Right(3) == "bmp")
  1806. {
  1807. GetEncoderClsid(L"image/bmp", &encoderClsid);
  1808. img->Save(bstr, &encoderClsid, NULL);
  1809. }
  1810. else if (path.Right(3) == "png")
  1811. {
  1812. GetEncoderClsid(L"image/png", &encoderClsid);
  1813. img->Save(bstr, &encoderClsid, NULL);
  1814. }
  1815. else// if(path.Right (3)=="jpg")
  1816. {
  1817. GetEncoderClsid(L"image/jpeg", &encoderClsid);
  1818. EncoderParameters encoderParameters;
  1819. ULONG quality;
  1820. encoderParameters.Count = 1;
  1821. encoderParameters.Parameter[0].Guid = EncoderQuality;
  1822. encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
  1823. encoderParameters.Parameter[0].NumberOfValues = 1;
  1824. // Save the image as a JPEG with quality level 100.
  1825. quality = 100;
  1826. encoderParameters.Parameter[0].Value = &quality;
  1827. img->Save(bstr, &encoderClsid, &encoderParameters);
  1828. }
  1829. SysFreeString(bstr);
  1830. }
  1831. catch (...)
  1832. {
  1833. }
  1834. }
  1835. int CNeroDlg::GetEncoderClsid( const WCHAR* format, CLSID* pClsid)
  1836. {
  1837. UINT num = 0; // number of image encoders
  1838. UINT size = 0; // size of the image encoder array in bytes
  1839. ImageCodecInfo* pImageCodecInfo = NULL;
  1840. GetImageEncodersSize(&num, &size);
  1841. if (size == 0)
  1842. return -1; // Failure
  1843. pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
  1844. if (pImageCodecInfo == NULL)
  1845. return -1; // Failure
  1846. GetImageEncoders(num, size, pImageCodecInfo);
  1847. for (UINT j = 0; j < num; ++j)
  1848. {
  1849. if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
  1850. {
  1851. *pClsid = pImageCodecInfo[j].Clsid;
  1852. free(pImageCodecInfo);
  1853. return j; // Success
  1854. }
  1855. }
  1856. free(pImageCodecInfo);
  1857. return -1; // FailureFailure
  1858. }