NeroDlg.cpp 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035
  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. for (int i = 0; i < dirarray.GetSize(); i++)
  409. {
  410. using namespace helper_coffs;
  411. ffsco o;
  412. o.dirs(0);
  413. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  414. ffsco::typeT coo;
  415. ffsco::typeT::iterator it;
  416. coo = o.co_file();
  417. for (it = coo.begin(); coo.end() != it; it++)
  418. {
  419. str = (*it).c_str();
  420. m_photoarray7.Add(str);
  421. }
  422. }
  423. if (m_photoarray7.GetSize() == 0)
  424. {
  425. AfxMessageBox("警告:目录中无照片!", MB_ICONSTOP);
  426. }
  427. m_nphotos = m_photoarray7.GetSize();
  428. m_nspase = 0;
  429. for (i = 0; i < m_photoarray7.GetSize(); i++)
  430. {
  431. CFile fp;
  432. if (fp.Open(m_photoarray7.ElementAt(i), CFile::modeRead))
  433. {
  434. m_nspase += fp.GetLength();
  435. fp.Close();
  436. }
  437. }
  438. m_nspase /= (1024 * 1024);
  439. str.Format("照片:%d 占用空间:%dM", m_nphotos, m_nspase);
  440. GetDlgItem(IDC_STATIC7)->SetWindowText(str);
  441. }
  442. void CNeroDlg::OnCheck1()
  443. {
  444. //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);
  445. UpdateData();
  446. if (m_checkphoto1)
  447. {
  448. if (m_photoarray1.GetSize() == 0)
  449. {
  450. CString path;
  451. path = g_path4 + "\\"; // 精修好的片;
  452. path += m_id;
  453. path += "\\";
  454. m_realpath = g_path4;
  455. CStringArray dirarray;
  456. CString str;
  457. using namespace helper_coffs;
  458. ffsco o;
  459. o.dirs(1);
  460. o.find(LPCSTR(path), LPCSTR("*.*"));
  461. ffsco::typeT coo;
  462. ffsco::typeT::iterator it;
  463. coo = o.co_dir();
  464. for (it = coo.begin(); coo.end() != it; it++)
  465. {
  466. str = (*it).c_str();
  467. if (FindArray(&dirarray, str) == -1)
  468. {
  469. dirarray.Add(str);
  470. }
  471. }
  472. for (int i = 0; i < dirarray.GetSize(); i++)
  473. {
  474. using namespace helper_coffs;
  475. ffsco o;
  476. o.dirs(0);
  477. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  478. ffsco::typeT coo;
  479. ffsco::typeT::iterator it;
  480. coo = o.co_file();
  481. for (it = coo.begin(); coo.end() != it; it++)
  482. {
  483. str = (*it).c_str();
  484. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  485. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  486. m_photoarray1.Add(str);
  487. }
  488. }
  489. if (m_photoarray1.GetSize() == 0)
  490. {
  491. AfxMessageBox("没有找到精修片,将用初修片替代!");
  492. path = g_path2 + "\\";
  493. path += m_id;
  494. path += "\\";
  495. m_realpath = g_path2;
  496. CStringArray dirarray;
  497. CString str, temp;
  498. using namespace helper_coffs;
  499. ffsco o;
  500. o.dirs(1);
  501. o.find(LPCSTR(path), LPCSTR("*.*"));
  502. ffsco::typeT coo;
  503. ffsco::typeT::iterator it;
  504. coo = o.co_dir();
  505. for (it = coo.begin(); coo.end() != it; it++)
  506. {
  507. str = (*it).c_str();
  508. if (FindArray(&dirarray, str) == -1)
  509. {
  510. dirarray.Add(str);
  511. }
  512. }
  513. for (int i = 0; i < dirarray.GetSize(); i++)
  514. {
  515. using namespace helper_coffs;
  516. ffsco o;
  517. o.dirs(0);
  518. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  519. ffsco::typeT coo;
  520. ffsco::typeT::iterator it;
  521. coo = o.co_file();
  522. for (it = coo.begin(); coo.end() != it; it++)
  523. {
  524. str = (*it).c_str();
  525. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  526. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  527. /* temp=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  528. temp=temp.Left (3);
  529. if(FindArray(&m_noarray, temp)==-1)
  530. continue;*/
  531. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  532. continue;
  533. m_photoarray1.Add(str);
  534. }
  535. }
  536. }
  537. if (m_photoarray1.GetSize() == 0)
  538. {
  539. AfxMessageBox("没有找到初修片,将用原片替代!");
  540. path = g_path1 + "\\";
  541. path += m_id;
  542. path += "\\";
  543. m_realpath = g_path1;
  544. CStringArray dirarray;
  545. CString str, temp;
  546. using namespace helper_coffs;
  547. ffsco o;
  548. o.dirs(1);
  549. o.find(LPCSTR(path), LPCSTR("*.*"));
  550. ffsco::typeT coo;
  551. ffsco::typeT::iterator it;
  552. coo = o.co_dir();
  553. for (it = coo.begin(); coo.end() != it; it++)
  554. {
  555. str = (*it).c_str();
  556. if (FindArray(&dirarray, str) == -1)
  557. {
  558. dirarray.Add(str);
  559. }
  560. }
  561. for (int i = 0; i < dirarray.GetSize(); i++)
  562. {
  563. using namespace helper_coffs;
  564. ffsco o;
  565. o.dirs(0);
  566. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  567. ffsco::typeT coo;
  568. ffsco::typeT::iterator it;
  569. coo = o.co_file();
  570. for (it = coo.begin(); coo.end() != it; it++)
  571. {
  572. str = (*it).c_str();
  573. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  574. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  575. /* temp=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  576. temp=temp.Left (3);
  577. if(FindArray(&m_noarray, temp)==-1)
  578. continue;*/
  579. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  580. continue;
  581. m_photoarray1.Add(str);
  582. }
  583. }
  584. }
  585. m_nphotos1 = m_photoarray1.GetSize();
  586. m_nspase1 = 0;
  587. for (i = 0; i < m_photoarray1.GetSize(); i++)
  588. {
  589. CFile fp;
  590. if (fp.Open(m_photoarray1.ElementAt(i), CFile::modeRead))
  591. {
  592. m_nspase1 += fp.GetLength();
  593. fp.Close();
  594. }
  595. }
  596. m_nspase1temp = m_nspase1;
  597. }
  598. else
  599. {
  600. m_nphotos1 = m_photoarray1.GetSize();
  601. m_nspase1 = m_nspase1temp;
  602. }
  603. }
  604. else
  605. {
  606. m_nphotos1 = 0;
  607. m_nspase1 = 0;
  608. }
  609. CString str;
  610. str.Format("照片:%d 占用空间:%dM", m_nphotos1, m_nspase1 / (1024 * 1024));
  611. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  612. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  613. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  614. }
  615. void CNeroDlg::OnCheck2()
  616. {
  617. UpdateData();
  618. if (m_checkphoto2)
  619. {
  620. if (m_checkphoto5)
  621. m_checkphoto5 = 0;
  622. UpdateData(false);
  623. OnCheck5();
  624. if (m_photoarray2.GetSize() == 0)
  625. {
  626. CString path;
  627. path = g_path2 + "\\";
  628. path += m_id;
  629. path += "\\";
  630. CString str;
  631. if (m_noarray.GetSize() == 0)
  632. {
  633. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  634. return;
  635. }
  636. for (int i = 0; i < m_noarray.GetSize(); i++)
  637. {
  638. str.Format("%s%s.jpg", path, m_noarray.ElementAt(i));
  639. if (PathFileExists(str))
  640. {
  641. m_photoarray2.Add(str);
  642. }
  643. }
  644. if (m_photoarray2.GetSize() == 0)
  645. {
  646. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  647. }
  648. m_nphotos2 = m_photoarray2.GetSize();
  649. m_nspase2 = 0;
  650. for (i = 0; i < m_photoarray2.GetSize(); i++)
  651. {
  652. CFile fp;
  653. if (fp.Open(m_photoarray2.ElementAt(i), CFile::modeRead))
  654. {
  655. m_nspase2 += fp.GetLength();
  656. fp.Close();
  657. }
  658. }
  659. m_nspase2temp = m_nspase2;
  660. }
  661. else
  662. {
  663. m_nphotos2 = m_photoarray2.GetSize();
  664. m_nspase2 = m_nspase2temp;
  665. }
  666. }
  667. else
  668. {
  669. m_nphotos2 = 0;
  670. m_nspase2 = 0;
  671. }
  672. CString str;
  673. str.Format("照片:%d 占用空间:%dM", m_nphotos2, m_nspase2 / (1024 * 1024));
  674. GetDlgItem(IDC_STATIC2)->SetWindowText(str);
  675. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  676. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  677. }
  678. void CNeroDlg::OnCheck3()
  679. {
  680. // TODO: Add your control notification handler code here
  681. /* UpdateData();
  682. if(m_checkphoto3)
  683. {
  684. if(m_checkphoto4)
  685. m_checkphoto4=0;
  686. UpdateData(false);
  687. OnCheck4();
  688. if(m_photoarray3.GetSize ()==0)
  689. {
  690. CString path;
  691. path=g_path1+"\\";
  692. path+=m_id;
  693. path +="\\";
  694. if(m_noarray.GetSize ()==0)
  695. {
  696. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  697. return;
  698. }
  699. CString str;
  700. for(int i=0; i<m_noarray.GetSize (); i++)
  701. {
  702. str.Format ("%s%s.jpg", path, m_noarray.ElementAt (i));
  703. if(::CheckFolderFileExist (str))
  704. {
  705. m_photoarray3.Add (str);
  706. }
  707. }
  708. if(m_photoarray3.GetSize ()==0)
  709. {
  710. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  711. }
  712. m_nphotos3=m_photoarray3.GetSize ();
  713. m_nspase3=0;
  714. for( i=0; i<m_photoarray3.GetSize (); i++)
  715. {
  716. CFile fp;
  717. if(fp.Open (m_photoarray3.ElementAt (i), CFile::modeRead))
  718. {
  719. m_nspase3+=fp.GetLength ();
  720. fp.Close ();
  721. }
  722. }
  723. m_nspase3temp=m_nspase3;
  724. }
  725. else
  726. {
  727. m_nphotos3=m_photoarray3.GetSize ();
  728. m_nspase3=m_nspase3temp;
  729. }
  730. }
  731. else
  732. {
  733. m_nphotos3=0;
  734. m_nspase3=0;
  735. }
  736. CString str;
  737. str.Format ("照片:%d 占用空间:%dM", m_nphotos3, m_nspase3/(1024*1024));
  738. GetDlgItem(IDC_STATIC3)->SetWindowText(str);
  739. m_nphotos=m_nphotos1+m_nphotos2+m_nphotos3+m_nphotos4+m_nphotos5+m_nphotos6;
  740. m_nspase=(m_nspase1+m_nspase2+m_nspase3+m_nspase4+m_nspase5+m_nspase6)/(1024*1024);
  741. */
  742. }
  743. void CNeroDlg::OnCheck4()
  744. {
  745. UpdateData();
  746. if (m_checkphoto4)
  747. {
  748. /* if(m_checkphoto3)
  749. m_checkphoto3=0;
  750. UpdateData(false);
  751. OnCheck3();*/
  752. if (m_photoarray4.GetSize() == 0)
  753. {
  754. CString path;
  755. path = g_path1 + "\\";
  756. path += m_id;
  757. path += "\\";
  758. CStringArray dirarray;
  759. CString str;
  760. using namespace helper_coffs;
  761. ffsco o;
  762. o.dirs(1);
  763. o.find(LPCSTR(path), LPCSTR("*.*"));
  764. ffsco::typeT coo;
  765. ffsco::typeT::iterator it;
  766. coo = o.co_dir();
  767. for (it = coo.begin(); coo.end() != it; it++)
  768. {
  769. str = (*it).c_str();
  770. if (FindArray(&dirarray, str) == -1)
  771. {
  772. dirarray.Add(str);
  773. }
  774. }
  775. for (int i = 0; i < dirarray.GetSize(); i++)
  776. {
  777. using namespace helper_coffs;
  778. ffsco o;
  779. o.dirs(0);
  780. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  781. ffsco::typeT coo;
  782. ffsco::typeT::iterator it;
  783. coo = o.co_file();
  784. for (it = coo.begin(); coo.end() != it; it++)
  785. {
  786. str = (*it).c_str();
  787. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  788. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  789. m_photoarray4.Add(str);
  790. }
  791. }
  792. if (m_photoarray4.GetSize() == 0)
  793. {
  794. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  795. }
  796. m_nphotos4 = m_photoarray4.GetSize();
  797. m_nspase4 = 0;
  798. for (i = 0; i < m_photoarray4.GetSize(); i++)
  799. {
  800. CFile fp;
  801. if (fp.Open(m_photoarray4.ElementAt(i), CFile::modeRead))
  802. {
  803. m_nspase4 += fp.GetLength();
  804. fp.Close();
  805. }
  806. }
  807. m_nspase4temp = m_nspase4;
  808. }
  809. else
  810. {
  811. m_nphotos4 = m_photoarray4.GetSize();
  812. m_nspase4 = m_nspase4temp;
  813. }
  814. }
  815. else
  816. {
  817. m_nphotos4 = 0;
  818. m_nspase4 = 0;
  819. }
  820. CString str;
  821. str.Format("照片:%d 占用空间:%dM", m_nphotos4, m_nspase4 / (1024 * 1024));
  822. GetDlgItem(IDC_STATIC4)->SetWindowText(str);
  823. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  824. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  825. }
  826. void CNeroDlg::OnCheck5()
  827. {
  828. UpdateData();
  829. if (m_checkphoto5)
  830. {
  831. if (m_checkphoto2)
  832. m_checkphoto2 = 0;
  833. UpdateData(false);
  834. OnCheck2();
  835. if (m_photoarray5.GetSize() == 0)
  836. {
  837. CString path;
  838. path = g_path2 + "\\";
  839. path += m_id;
  840. path += "\\";
  841. CStringArray dirarray;
  842. CString str;
  843. using namespace helper_coffs;
  844. ffsco o;
  845. o.dirs(1);
  846. o.find(LPCSTR(path), LPCSTR("*.*"));
  847. ffsco::typeT coo;
  848. ffsco::typeT::iterator it;
  849. coo = o.co_dir();
  850. for (it = coo.begin(); coo.end() != it; it++)
  851. {
  852. str = (*it).c_str();
  853. if (FindArray(&dirarray, str) == -1)
  854. {
  855. dirarray.Add(str);
  856. }
  857. }
  858. for (int i = 0; i < dirarray.GetSize(); i++)
  859. {
  860. using namespace helper_coffs;
  861. ffsco o;
  862. o.dirs(0);
  863. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  864. ffsco::typeT coo;
  865. ffsco::typeT::iterator it;
  866. coo = o.co_file();
  867. for (it = coo.begin(); coo.end() != it; it++)
  868. {
  869. str = (*it).c_str();
  870. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  871. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  872. m_photoarray5.Add(str);
  873. }
  874. }
  875. if (m_photoarray5.GetSize() == 0)
  876. {
  877. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  878. }
  879. m_nphotos5 = m_photoarray5.GetSize();
  880. m_nspase5 = 0;
  881. for (i = 0; i < m_photoarray5.GetSize(); i++)
  882. {
  883. CFile fp;
  884. if (fp.Open(m_photoarray5.ElementAt(i), CFile::modeRead))
  885. {
  886. m_nspase5 += fp.GetLength();
  887. fp.Close();
  888. }
  889. }
  890. m_nspase5temp = m_nspase5;
  891. }
  892. else
  893. {
  894. m_nphotos5 = m_photoarray5.GetSize();
  895. m_nspase5 = m_nspase5temp;
  896. }
  897. }
  898. else
  899. {
  900. m_nphotos5 = 0;
  901. m_nspase5 = 0;
  902. }
  903. CString str;
  904. str.Format("照片:%d 占用空间:%dM", m_nphotos5, m_nspase5 / (1024 * 1024));
  905. GetDlgItem(IDC_STATIC5)->SetWindowText(str);
  906. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  907. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  908. }
  909. void CNeroDlg::OnCheck6()
  910. {
  911. UpdateData();
  912. if (m_checkphoto6)
  913. {
  914. if (m_photoarray6.GetSize() == 0)
  915. {
  916. CString path;
  917. path = g_path3 + "\\";
  918. path += m_id;
  919. path += "\\";
  920. CStringArray dirarray;
  921. CString str;
  922. using namespace helper_coffs;
  923. ffsco o;
  924. o.dirs(1);
  925. o.find(LPCSTR(path), LPCSTR("*.*"));
  926. ffsco::typeT coo;
  927. ffsco::typeT::iterator it;
  928. coo = o.co_dir();
  929. for (it = coo.begin(); coo.end() != it; it++)
  930. {
  931. str = (*it).c_str();
  932. if (FindArray(&dirarray, str) == -1)
  933. {
  934. dirarray.Add(str);
  935. }
  936. }
  937. for (int i = 0; i < dirarray.GetSize(); i++)
  938. {
  939. using namespace helper_coffs;
  940. ffsco o;
  941. o.dirs(0);
  942. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  943. ffsco::typeT coo;
  944. ffsco::typeT::iterator it;
  945. coo = o.co_file();
  946. for (it = coo.begin(); coo.end() != it; it++)
  947. {
  948. str = (*it).c_str();
  949. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  950. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  951. m_photoarray6.Add(str);
  952. }
  953. }
  954. if (m_photoarray6.GetSize() == 0)
  955. {
  956. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  957. }
  958. m_nphotos6 = m_photoarray6.GetSize();
  959. m_nspase6 = 0;
  960. for (i = 0; i < m_photoarray6.GetSize(); i++)
  961. {
  962. CFile fp;
  963. if (fp.Open(m_photoarray6.ElementAt(i), CFile::modeRead))
  964. {
  965. m_nspase6 += fp.GetLength();
  966. fp.Close();
  967. }
  968. }
  969. m_nspase6temp = m_nspase6;
  970. }
  971. else
  972. {
  973. m_nphotos6 = m_photoarray6.GetSize();
  974. m_nspase6 = m_nspase6temp;
  975. }
  976. }
  977. else
  978. {
  979. m_nphotos6 = 0;
  980. m_nspase6 = 0;
  981. }
  982. CString str;
  983. str.Format("照片:%d 占用空间:%dM", m_nphotos6, m_nspase6 / (1024 * 1024));
  984. GetDlgItem(IDC_STATIC6)->SetWindowText(str);
  985. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  986. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  987. }
  988. //-----------------------------------------------------------------
  989. // remark by Jeff 2014-12-12
  990. // 函数:GetNo
  991. // 描述:从str中解析出每个相片名,然后存入空的CStringArray中;
  992. // 参数:
  993. // str:选好的相片名串,如:"001,002,003" 后分隔符改为"|",结果应是"001|002|003"
  994. // array:空的数组,用来存放解析后的相片名;
  995. // 返回:
  996. // 注意:更换分隔符造成的问题,在该函数已解决;
  997. //-----------------------------------------------------------------
  998. void CNeroDlg::GetNo(CString str, CStringArray &array)
  999. {
  1000. if (!str.IsEmpty())
  1001. {
  1002. int pos = str.Find(",");
  1003. while (pos != -1)
  1004. {
  1005. if (FindArray(&array, str.Left(pos)) == -1)
  1006. array.Add(str.Left(pos));
  1007. str = str.Right(str.GetLength() - pos - 1);
  1008. pos = str.Find(",");
  1009. }
  1010. if (FindArray(&array, str) == -1)
  1011. array.Add(str);
  1012. }
  1013. }
  1014. extern bool SleepEx(DWORD dwMilliseconds);
  1015. //extern void DeleteDirectory(CString strDir);
  1016. void CNeroDlg::OnOK()
  1017. {
  1018. ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录;
  1019. ::CreateDirectory(g_mainpath + "\\temp", NULL);
  1020. UpdateData();
  1021. if (m_bScale)
  1022. {
  1023. if (!CheckDiskSpase())return;
  1024. }
  1025. if (m_nphotos == 0)
  1026. {
  1027. AfxMessageBox("未选中照片!", MB_ICONSTOP);
  1028. return;
  1029. }
  1030. if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0)
  1031. {
  1032. AfxMessageBox("光盘空间不足!", MB_ICONSTOP);
  1033. return;
  1034. }
  1035. m_Burn.m_DirArray.RemoveAll();
  1036. m_Burn.m_DirRealNameArray.RemoveAll();
  1037. CArray<BOOL, BOOL>bIsSelectDirArray;
  1038. GetDlgItem(IDOK)->SetWindowText("刻录中, 请稍候...");
  1039. GetDlgItem(IDOK)->EnableWindow(0);
  1040. if (NowDoingBurn)
  1041. return;
  1042. CStringArray dirarray;
  1043. using namespace helper_coffs;
  1044. CStringArray srcarray;
  1045. if (m_bFromDir)
  1046. {
  1047. CString str;
  1048. GetDlgItemText(IDC_EDIT1, str);
  1049. str.TrimRight('\\');
  1050. m_Burn.m_DirArray.Add(str);
  1051. m_Burn.m_DirRealNameArray.Add(str);
  1052. bIsSelectDirArray.Add(0);
  1053. }
  1054. else
  1055. {
  1056. if (m_checkphoto1)
  1057. {
  1058. if (m_realpath == g_path1 && m_checkphoto4)//没有精修片用原片代替,同时又要刻原片时, 把原片备份出来
  1059. {
  1060. SetDlgItemText(IDC_STATICTip, "照片复制中...");
  1061. m_Progress.SetRange(0, m_photoarray1.GetSize());
  1062. CString path = g_mainpath + "\\temp\\" + m_id + "(精修)";
  1063. ::CreateDirectory(path, NULL);
  1064. CString str;
  1065. for (int i = 0; i < m_photoarray1.GetSize(); i++)
  1066. {
  1067. str = m_photoarray1.ElementAt(i);
  1068. ::CopyFile(str, path + str.Right(str.GetLength() - str.ReverseFind('\\')), 0);
  1069. m_Progress.SetPos(i);
  1070. }
  1071. m_Burn.m_DirArray.Add(path);
  1072. m_Burn.m_DirRealNameArray.Add(path);
  1073. bIsSelectDirArray.Add(0);
  1074. }
  1075. else
  1076. {
  1077. m_Burn.m_DirArray.Add(m_realpath + "\\" + m_id);
  1078. m_Burn.m_DirRealNameArray.Add(m_realpath + "\\" + m_id + "(精修)");
  1079. if (m_realpath == g_path4)
  1080. bIsSelectDirArray.Add(0);
  1081. else
  1082. bIsSelectDirArray.Add(1);
  1083. }
  1084. }
  1085. if (m_checkphoto5)
  1086. {
  1087. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
  1088. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
  1089. bIsSelectDirArray.Add(0);
  1090. }
  1091. if (m_checkphoto4)
  1092. {
  1093. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
  1094. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
  1095. bIsSelectDirArray.Add(0);
  1096. }
  1097. if (m_checkphoto6)
  1098. {
  1099. m_Burn.m_DirArray.Add(g_path3 + "\\" + m_id);
  1100. m_Burn.m_DirRealNameArray.Add(g_path3 + "\\" + m_id + "(设计片)");
  1101. bIsSelectDirArray.Add(0);
  1102. }
  1103. }
  1104. DWORD nNeedSpase = 0;
  1105. if (m_bScale)
  1106. {
  1107. SetDlgItemText(IDC_STATICTip, "照片裁切中...");
  1108. int pos = m_combo1.GetCurSel();
  1109. CStringArray needsaclearray;
  1110. CStringArray dirarray;
  1111. for (int i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1112. {
  1113. GenSPhoto(m_Burn.m_DirArray.ElementAt(i), m_Burn.m_DirRealNameArray.ElementAt(i).Right(6), needsaclearray, dirarray);
  1114. }
  1115. m_Progress.SetRange(0, needsaclearray.GetSize());
  1116. for (i = 0; i < needsaclearray.GetSize(); i++)
  1117. {
  1118. CString str = needsaclearray.ElementAt(i);
  1119. CString dir;
  1120. dir = dirarray.ElementAt(i);
  1121. Image *img = NULL;
  1122. ::LoadImageFromBuf(&img, str);
  1123. if (img->GetWidth())
  1124. {
  1125. CRect rc(0, 0, 800, 800);
  1126. if (pos == 0)
  1127. {
  1128. rc.right = 1600;
  1129. rc.bottom = 1600;
  1130. }
  1131. else if (pos == 1)
  1132. {
  1133. rc.right = 1024;
  1134. rc.bottom = 1024;
  1135. }
  1136. else if (pos == 2)
  1137. {
  1138. rc.right = 800;
  1139. rc.bottom = 800;
  1140. }
  1141. else
  1142. {
  1143. rc.right = 640;
  1144. rc.bottom = 640;
  1145. }
  1146. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  1147. Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
  1148. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  1149. graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight());
  1150. delete img;
  1151. CString savepath = dir + "\\" + ::GetFileNameFromPath(str) + ".jpg";
  1152. ::SaveImageToFile(simg, savepath);
  1153. delete simg;
  1154. CFile fp;
  1155. if (fp.Open(savepath, CFile::modeRead))
  1156. {
  1157. nNeedSpase += fp.GetLength();
  1158. fp.Close();
  1159. }
  1160. else
  1161. {
  1162. /* ::CopyFile (str, savepath, 0);
  1163. if(fp.Open (savepath, CFile::modeRead))
  1164. {
  1165. nNeedSpase+=fp.GetLength ();
  1166. fp.Close ();
  1167. }*/
  1168. str.Format("原片%s裁剪失败, 请查看此照片是否损坏。", savepath.Right(savepath.GetLength() - savepath.ReverseFind('\\') - 1));
  1169. AfxMessageBox(str);
  1170. }
  1171. }
  1172. m_Progress.SetPos(i + 1);
  1173. ::SleepEx(10);
  1174. }
  1175. if (::CheckFolderFileExist(g_mainpath + "\\temp\\" + m_id + "(未选的照片)"))
  1176. {
  1177. m_Burn.m_DirArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
  1178. m_Burn.m_DirRealNameArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
  1179. bIsSelectDirArray.Add(0);
  1180. }
  1181. }
  1182. SetDlgItemText(IDC_STATICTip, "光盘刻录中...");
  1183. CString str;
  1184. CArray<BOOL, BOOL>bIsSelectDirArray2;
  1185. for (int i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1186. {
  1187. ffsco o;
  1188. o.dirs(1);
  1189. o.find(LPCSTR(m_Burn.m_DirArray.ElementAt(i)), LPCSTR("*.*"));
  1190. ffsco::typeT coo;
  1191. ffsco::typeT::iterator it;
  1192. coo = o.co_dir();
  1193. for (it = coo.begin(); coo.end() != it; it++)
  1194. {
  1195. str = (*it).c_str();
  1196. str.TrimRight("\\");
  1197. if (FindArray(&dirarray, str) == -1)
  1198. {
  1199. dirarray.Add(str);
  1200. bIsSelectDirArray2.Add(bIsSelectDirArray.ElementAt(i));
  1201. }
  1202. }
  1203. }
  1204. int addcount = 0;
  1205. if (m_bFromDir == 0)
  1206. {
  1207. if (m_checkphoto2)addcount++;
  1208. if (m_checkphoto3)addcount++;
  1209. }
  1210. if ((dirarray.GetSize() + addcount) == 0)return;
  1211. CStringArray *photosarray = new CStringArray[dirarray.GetSize() + addcount];
  1212. for (i = 0; i < dirarray.GetSize(); i++)
  1213. {
  1214. GenSPhoto(dirarray.ElementAt(i), photosarray[i], nNeedSpase, bIsSelectDirArray2.ElementAt(i));
  1215. }
  1216. if (m_bFromDir == 0)
  1217. {
  1218. int pos = dirarray.GetSize();
  1219. if (m_checkphoto2)
  1220. {
  1221. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
  1222. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
  1223. dirarray.Add(g_path2 + "\\" + m_id);
  1224. photosarray[pos].Copy(m_photoarray2);
  1225. pos++;
  1226. nNeedSpase += m_nspase1;
  1227. }
  1228. if (m_checkphoto3)
  1229. {
  1230. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
  1231. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
  1232. dirarray.Add(g_path1 + "\\" + m_id);
  1233. photosarray[pos].Copy(m_photoarray3);
  1234. nNeedSpase += m_nspase2;
  1235. }
  1236. }
  1237. if (m_bScale)
  1238. {
  1239. nNeedSpase /= 1024 * 1024;
  1240. if (nNeedSpase > 650 && m_bDvd == 0)
  1241. {
  1242. AfxMessageBox("光盘空间不足!", MB_ICONSTOP); delete[]photosarray;
  1243. return;
  1244. }
  1245. }
  1246. m_Burn.m_pDir = &dirarray;
  1247. m_Burn.m_pPhotoArray = photosarray;
  1248. if (m_Burn.NeroAPIInit() == 0)
  1249. {
  1250. m_Burn.NeroWorkError = 1;
  1251. delete[]photosarray;
  1252. return;
  1253. }
  1254. m_Burn.m_name = m_name;
  1255. m_Burn.m_bDvd = m_bDvd;
  1256. m_Burn.NeroAPIBurn();
  1257. NowDoingBurn = true;
  1258. delete[]photosarray;
  1259. ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录;
  1260. if (m_Burn.NeroWorkError == 0)
  1261. {
  1262. CDialog::OnOK();
  1263. }
  1264. else
  1265. CDialog::OnCancel();
  1266. }
  1267. void CNeroDlg::OnCheck7()
  1268. {
  1269. // TODO: Add your control notification handler code here
  1270. UpdateData();
  1271. CString version = _T("Version 1.0");
  1272. AfxGetApp()->WriteProfileInt(version, "cutphoto", m_bScale);
  1273. }
  1274. BOOL CNeroDlg::CheckDiskSpase()
  1275. {
  1276. CString sDrive = g_mainpath.Left(2);
  1277. DWORD dwTotalDiskSpace, dwFreeDiskSpace, dwUsedDiskSpace;
  1278. ULARGE_INTEGER uiFreeBytesAvailableToCaller;
  1279. ULARGE_INTEGER uiTotalNumberOfBytes;
  1280. ULARGE_INTEGER uiTotalNumberOfFreeBytes;
  1281. if (GetDiskFreeSpaceEx(sDrive, &uiFreeBytesAvailableToCaller,
  1282. &uiTotalNumberOfBytes,
  1283. &uiTotalNumberOfFreeBytes))
  1284. {
  1285. dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
  1286. dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
  1287. dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
  1288. }
  1289. if (dwFreeDiskSpace > 600)return 1;
  1290. AfxMessageBox("磁盘空间不足!", MB_ICONSTOP);
  1291. return 0;
  1292. }
  1293. void CNeroDlg::OnCloseupCombo1()
  1294. {
  1295. // TODO: Add your control notification handler code here
  1296. int pos = m_combo1.GetCurSel();
  1297. if (pos != -1)
  1298. {
  1299. CString version = _T("Version 1.0");
  1300. AfxGetApp()->WriteProfileInt(version, "cutphotosize", pos);
  1301. }
  1302. }
  1303. void CNeroDlg::OnRadio1()
  1304. {
  1305. // TODO: Add your control notification handler code here
  1306. OnRadio2();
  1307. }
  1308. void CNeroDlg::OnRadio2()
  1309. {
  1310. // TODO: Add your control notification handler code here
  1311. UpdateData();
  1312. CString version = _T("Version 1.0");
  1313. AfxGetApp()->WriteProfileInt(version, "bDvd", m_bDvd);
  1314. }
  1315. void CNeroDlg::OnDestroy()
  1316. {
  1317. UpdateData();
  1318. CString version = _T("Version 1.0");
  1319. AfxGetApp()->WriteProfileInt(version, "m_checkphoto1", m_checkphoto1);
  1320. AfxGetApp()->WriteProfileInt(version, "m_checkphoto2", m_checkphoto2);
  1321. AfxGetApp()->WriteProfileInt(version, "m_checkphoto3", m_checkphoto3);
  1322. AfxGetApp()->WriteProfileInt(version, "m_checkphoto4", m_checkphoto4);
  1323. AfxGetApp()->WriteProfileInt(version, "m_checkphoto5", m_checkphoto5);
  1324. AfxGetApp()->WriteProfileInt(version, "m_checkphoto6", m_checkphoto6);
  1325. // TODO: Add your message handler code here
  1326. CDialog::OnDestroy();
  1327. }
  1328. //---------------------------------------------------------------------------------------------------
  1329. //---------------------------------------------------------------------------------------------------
  1330. /************************************************************************/
  1331. /*
  1332. Jeff add 2014.09.03
  1333. */
  1334. /************************************************************************/
  1335. BOOL CopyFolder(CString strSrcPath, CString strDstPath)
  1336. {
  1337. // 创建目标文件夹;
  1338. if (strSrcPath.Right(1) == "\\")
  1339. {
  1340. strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
  1341. }
  1342. if (strDstPath.Right(1) == "\\")
  1343. {
  1344. strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
  1345. }
  1346. CreateDirectory(strDstPath, NULL);
  1347. CFileFind finder;
  1348. // 打开指定的文件夹进行搜索;
  1349. BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*");
  1350. while (bWorking)
  1351. {
  1352. // 从当前目录搜索文件;
  1353. bWorking = finder.FindNextFile();
  1354. CString strFileName = finder.GetFileName();
  1355. CString strSrc = strSrcPath + "\\" + strFileName;
  1356. CString strDst = strDstPath + "\\" + strFileName;
  1357. // 判断搜索到的是不是"."和".."目录;
  1358. if (!finder.IsDots())
  1359. {
  1360. // 判断搜索到的目录是否是文件夹;
  1361. if (finder.IsDirectory())
  1362. {
  1363. // 如果是文件夹的话,进行递归;
  1364. if (!CopyFolder(strSrc, strDst))
  1365. {
  1366. return false;
  1367. }
  1368. }
  1369. else
  1370. {
  1371. // 如果是文件,进行复制;
  1372. if (!CopyFile(strSrc, strDst, FALSE))
  1373. {
  1374. return false;
  1375. }
  1376. }
  1377. }
  1378. }
  1379. return true;
  1380. }
  1381. void CNeroDlg::OnBnClickedExporttou()
  1382. {
  1383. // 1.浏览文件U盘文件夹;
  1384. EndofThread();
  1385. //CString sFolderPath;
  1386. BROWSEINFO bi;
  1387. char Buffer[MAX_PATH];
  1388. //初始化入口参数bi开始;
  1389. bi.hwndOwner = NULL;
  1390. bi.pidlRoot = NULL;//初始化制定的root目录很不容易,
  1391. bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框;
  1392. bi.lpszTitle = "修改接收路径";
  1393. //bi.ulFlags = BIF_BROWSEINCLUDEFILES;//包括文件;
  1394. bi.ulFlags = BIF_EDITBOX | BIF_USENEWUI;//包括文件;
  1395. bi.lpfn = NULL;
  1396. bi.iImage = IDR_MAINFRAME;
  1397. //初始化入口参数bi结束;
  1398. LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框;
  1399. if (pIDList)
  1400. {
  1401. if (!SHGetPathFromIDList(pIDList, Buffer))
  1402. return;
  1403. //取得文件夹路径到Buffer里;
  1404. //sFolderPath = Buffer;//将文件夹路径保存在一个CString对象里;
  1405. m_strUFolder = Buffer;
  1406. }
  1407. else
  1408. return;
  1409. LPMALLOC lpMalloc;
  1410. if (FAILED(SHGetMalloc(&lpMalloc)))
  1411. return;
  1412. lpMalloc->Free(pIDList);
  1413. lpMalloc->Release();
  1414. // MessageBox(sFolderPath,"Title",MB_OK);
  1415. // 1.2.获取盘符;
  1416. BYTE bAlpha = m_strUFolder.GetAt(0);
  1417. if (m_strUFolder.GetLength() != m_strUFolder.ReverseFind('\\'))
  1418. {
  1419. m_strUFolder += "\\";
  1420. }
  1421. //printf("Jeff:保存目录 %s\n\n",m_strUFolder);
  1422. // 2.获取U盘的大小等信息;
  1423. CString strResult = _T("");
  1424. #if 1
  1425. __int64 iVolumeSize = 0, iVolumeFreeSize = 0;
  1426. #else
  1427. double iVolumeSize = 0.0, iVolumeFreeSize = 0.0;
  1428. #endif
  1429. if (!::IsCharAlpha((TCHAR)bAlpha))
  1430. {
  1431. strResult = _T("驱动器参数无效!");
  1432. //return strResult;
  1433. AfxMessageBox(strResult);
  1434. return;
  1435. }
  1436. else
  1437. {
  1438. /**********获取驱动器名字、序列号和文件系统部分**********/
  1439. CString strRootPathName;
  1440. strRootPathName.Format(_T("%c:\\"), bAlpha);
  1441. LPCTSTR lpRootPathName = strRootPathName;
  1442. LPTSTR lpVolumeNameBuffer = new char[_MAX_FNAME];
  1443. DWORD nVolumeNameSize = _MAX_FNAME;
  1444. DWORD nVolumeSerialNumber = 0;//便于驱动器无效时做判断 ;
  1445. DWORD nMaximumComponentLength;
  1446. DWORD nFileSystemFlags;
  1447. LPTSTR lpFileSystemNameBuffer = new char[20];//文件系统(NTFS,FAT)多大有定义好的宏吗 ;
  1448. DWORD nFileSystemNameSize = 20;
  1449. GetVolumeInformation(
  1450. lpRootPathName,
  1451. lpVolumeNameBuffer,
  1452. nVolumeNameSize,
  1453. &nVolumeSerialNumber,
  1454. &nMaximumComponentLength,
  1455. &nFileSystemFlags,
  1456. lpFileSystemNameBuffer,
  1457. nFileSystemNameSize);
  1458. /**********获取驱动器类型部分**********/
  1459. CString strDriveType;
  1460. /**********获取驱动器总大小和剩余大小部分**********/
  1461. LPCTSTR lpDirectoryName = new char[2];
  1462. lpDirectoryName = (LPCTSTR)strRootPathName.Mid(0, 2);
  1463. _ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
  1464. GetDiskFreeSpaceEx(strRootPathName.Mid(0, 2), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
  1465. #if 0
  1466. iVolumeSize = (double)TotalNumberOfBytes.QuadPart / 1024 / 1024;
  1467. iVolumeFreeSize = (double)FreeBytesAvailable.QuadPart / 1024 / 1024;
  1468. #else
  1469. iVolumeSize = TotalNumberOfBytes.QuadPart;
  1470. iVolumeFreeSize = FreeBytesAvailable.QuadPart;
  1471. #endif
  1472. }
  1473. // 3.对比大小;
  1474. DWORD64 dwTotalSize = m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6;
  1475. if ((iVolumeFreeSize <= dwTotalSize) || (iVolumeFreeSize - dwTotalSize < 1024 * 10)) // 相差10K,认为容量不足;
  1476. {
  1477. AfxMessageBox("U盘容量不足!");
  1478. return;
  1479. }
  1480. // 4.拷贝文件 精修片 原片 初修片 设计片;
  1481. // m_id; // 订单号;
  1482. CString strOrderFolder = _T("");
  1483. // 设置进度条;
  1484. DWORD nTotalFiles = m_photoarray1.GetSize() + m_photoarray6.GetSize() + m_photoarray5.GetSize() + m_photoarray4.GetSize();
  1485. m_Progress.SetRange(0, nTotalFiles);
  1486. // 5.由线程处理U盘的拷贝工作;
  1487. StartThread();
  1488. GetDlgItem(Btn_ExportToU)->EnableWindow(FALSE);
  1489. }
  1490. DWORD WINAPI CNeroDlg::ExportImageThread(LPVOID lpParam)
  1491. {
  1492. CNeroDlg *pExportImageImpl = (CNeroDlg*)lpParam;
  1493. int nIndexOfProcess = 0;
  1494. CString strImageName = _T("");
  1495. CString strOrderFolder = _T("");
  1496. strOrderFolder.Format("%s%s\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1497. ::CreateDirectory(strOrderFolder, NULL);
  1498. if (pExportImageImpl->m_bScale)
  1499. {
  1500. int nX = 0, nY = 0;
  1501. int nPos = pExportImageImpl->m_combo1.GetCurSel();
  1502. if (nPos == 0)
  1503. {
  1504. nY = 1200;
  1505. nX = 1600;
  1506. }
  1507. else if (nPos == 1)
  1508. {
  1509. nY = 768;
  1510. nX = 1024;
  1511. }
  1512. else if (nPos = 2)
  1513. {
  1514. nY = 600;
  1515. nX = 800;
  1516. }
  1517. else if (nPos == 3)
  1518. {
  1519. nY = 480;
  1520. nX = 640;
  1521. }
  1522. //printf("Jeff:%s,%s\n\n",pExportImageImpl->m_strUFolder,pExportImageImpl->m_id);
  1523. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  1524. {
  1525. strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1526. ::CreateDirectory(strOrderFolder, NULL);
  1527. //printf("Jeff:1.%s\n\n",strOrderFolder);
  1528. int nSize = pExportImageImpl->m_photoarray1.GetSize();//printf("Jeff:1.%d\n\n",nSize);
  1529. for (int i = 0; i < nSize; i++)
  1530. {
  1531. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  1532. //printf("Jeff:1.%s\n\n",strImageName);
  1533. ToCompressImage(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, nX, nY);
  1534. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1535. }
  1536. }
  1537. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  1538. {
  1539. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1540. ::CreateDirectory(strOrderFolder, NULL);
  1541. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  1542. for (int i = 0; i < nSize; i++)
  1543. {
  1544. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  1545. //printf("Jeff:6.%s,%s\n\n",pExportImageImpl->m_photoarray1.ElementAt(i),strImageName);
  1546. ToCompressImage(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, nX, nY);
  1547. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1548. }
  1549. }
  1550. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  1551. {
  1552. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1553. ::CreateDirectory(strOrderFolder, NULL);
  1554. //printf("Jeff:5.%s\n\n",strOrderFolder);
  1555. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  1556. for (int i = 0; i < nSize; i++)
  1557. {
  1558. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  1559. ToCompressImage(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, nX, nY);
  1560. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1561. }
  1562. }
  1563. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  1564. {
  1565. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1566. ::CreateDirectory(strOrderFolder, NULL);
  1567. //printf("Jeff:4.%s\n\n",strOrderFolder);
  1568. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  1569. for (int i = 0; i < nSize; i++)
  1570. {
  1571. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  1572. ToCompressImage(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, nX, nY);
  1573. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1574. }
  1575. }
  1576. }
  1577. else
  1578. {
  1579. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  1580. {
  1581. strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1582. ::CreateDirectory(strOrderFolder, NULL);
  1583. int nSize = pExportImageImpl->m_photoarray1.GetSize();
  1584. for (int i = 0; i < nSize; i++)
  1585. {
  1586. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  1587. ::CopyFile(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, 0);
  1588. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1589. }
  1590. }
  1591. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  1592. {
  1593. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1594. ::CreateDirectory(strOrderFolder, NULL);
  1595. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  1596. for (int i = 0; i < nSize; i++)
  1597. {
  1598. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  1599. ::CopyFile(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, 0);
  1600. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1601. }
  1602. }
  1603. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  1604. {
  1605. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1606. ::CreateDirectory(strOrderFolder, NULL);
  1607. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  1608. for (int i = 0; i < nSize; i++)
  1609. {
  1610. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  1611. ::CopyFile(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, 0);
  1612. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1613. }
  1614. }
  1615. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  1616. {
  1617. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
  1618. ::CreateDirectory(strOrderFolder, NULL);
  1619. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  1620. for (int i = 0; i < nSize; i++)
  1621. {
  1622. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  1623. ::CopyFile(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, 0);
  1624. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  1625. }
  1626. }
  1627. }
  1628. Sleep(1000);
  1629. AfxMessageBox("导出完毕!");
  1630. pExportImageImpl->GetDlgItem(Btn_ExportToU)->EnableWindow(TRUE);
  1631. pExportImageImpl->m_Progress.SetRange(0, 0);
  1632. //pExportImageImpl->m_Progress.SetPos(0);
  1633. return 0;
  1634. }
  1635. int CNeroDlg::StartThread()
  1636. {
  1637. m_hCtrl = CreateEvent(NULL, TRUE, FALSE, NULL); // 无信号事件;
  1638. if (m_hCtrl == NULL)
  1639. {
  1640. //LOG4C((LOG_NOTICE,"创建事件失败"));
  1641. //PostMessage(g_hwnd,MSG_SHOWPROMPTING,0,0);
  1642. return -1;
  1643. }
  1644. //_hThread = CreateThread(NULL,0,ThreadProc,this,CREATE_SUSPENDED,NULL);
  1645. m_hThread = CreateThread(NULL, 0, ExportImageThread, this, 0, NULL);
  1646. if (m_hThread == NULL)
  1647. {
  1648. //LOG4C((LOG_NOTICE,"创建线程失败"));
  1649. return -1;
  1650. }
  1651. //m_bThreadRuning = FALSE;
  1652. m_bThreadRuning = TRUE;
  1653. return 0;
  1654. }
  1655. int CNeroDlg::EndofThread()
  1656. {
  1657. // 1.关闭线程------------------------;;
  1658. if (m_hCtrl)
  1659. {
  1660. SetEvent(m_hCtrl);
  1661. }
  1662. if (m_hThread)
  1663. {
  1664. if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT)
  1665. {
  1666. CloseHandle(m_hThread);
  1667. m_hThread = NULL;
  1668. }
  1669. }
  1670. m_bThreadRuning = FALSE;
  1671. CloseHandle(m_hCtrl);
  1672. m_hCtrl = NULL;
  1673. return 0;
  1674. }
  1675. void CNeroDlg::ToCompressImage(__in const TCHAR *pImageSource, __in const TCHAR *pImageDest, __in const int &nXPiexel, __in const int &nYPiexel)
  1676. {
  1677. //printf("Jeff:%s,%s,%d,%d\n\n",pImageSource,pImageDest,nXPiexel,nYPiexel);
  1678. #if 1
  1679. Image *pImage = NULL;
  1680. #else
  1681. Bitmap *pImage = NULL;
  1682. #endif
  1683. // 1.从文件中以读的方式加载图片到Image中;
  1684. CFile cf;
  1685. if (cf.Open(pImageSource, CFile::modeRead))
  1686. {
  1687. DWORD dwLength = cf.GetLength();
  1688. BYTE *pData = new BYTE[dwLength];
  1689. if (pData == NULL)// 创建内存失败;
  1690. {
  1691. //printf("Jeff:1.创建内存失败\n\n");
  1692. return;
  1693. }
  1694. cf.Read(pData, dwLength);
  1695. cf.Close();
  1696. // 1.1.将文件数据加载到内存数据中;
  1697. HGLOBAL taghMem = GlobalAlloc(GMEM_MOVEABLE, dwLength);
  1698. if (taghMem == NULL) // 创建内存失败;
  1699. {
  1700. //printf("Jeff:2.创建内存失败\n\n");
  1701. return;
  1702. }
  1703. BYTE *pMem = (BYTE*)GlobalLock(taghMem);
  1704. memcpy(pMem, pData, dwLength);
  1705. // 1.2.创建二进制流对象;
  1706. IStream *pStream;
  1707. CreateStreamOnHGlobal(taghMem, TRUE, &pStream);
  1708. #if 1
  1709. pImage = Gdiplus::Image::FromStream(pStream);
  1710. #else
  1711. pImage = Gdiplus::Bitmap::FromStream(pStream);
  1712. #endif
  1713. GlobalUnlock(taghMem);
  1714. pStream->Release();
  1715. delete[]pData;
  1716. }
  1717. else
  1718. {
  1719. //printf("Jeff:打开文件失败\n\n");
  1720. }
  1721. // 2.加载后……
  1722. if (pImage == NULL) // 加载失败;
  1723. {
  1724. //printf("Jeff:加载图片失败\n\n");
  1725. return;
  1726. }
  1727. // 2.1.当图片的像素大于要设定的像素时,进行处理;
  1728. if (pImage->GetWidth() > nXPiexel || pImage->GetHeight() > nYPiexel)
  1729. {
  1730. CRect tagRect(0, 0, nXPiexel, nYPiexel);
  1731. RectFitDes_01(pImage->GetWidth(), pImage->GetHeight(), tagRect);
  1732. Image *RtImage = pImage->GetThumbnailImage(tagRect.Width(), tagRect.Height(), NULL, NULL);
  1733. Graphics graphic(RtImage); // 防止GetThumbnailImage影响图片质量;
  1734. delete pImage;
  1735. SaveImageToFile(RtImage, pImageDest);
  1736. delete RtImage;
  1737. }
  1738. else // 直接用原片,不压缩;
  1739. {
  1740. ::CopyFile(pImageSource, pImageDest, 0);
  1741. }
  1742. }
  1743. void CNeroDlg::RectFitDes_01(__in const int &nWidth, __in const int &nHeight, __inout CRect &rc)
  1744. {
  1745. try
  1746. {
  1747. if (nWidth == 0 || nHeight == 0)return;
  1748. // 图片长宽比例;
  1749. float fscale = (float)nWidth / (float)nHeight;
  1750. // 设备长宽比例;
  1751. float rcscale = ((float)rc.Width()) / ((float)rc.Height());
  1752. int rcwid = rc.Width();
  1753. int rchei = rc.Height();
  1754. int dt = 0;
  1755. // Jeff.如果设备长宽比例 < 图片长宽比例;(即相同长度下,高越大比例值越小,所以此时图片尺寸 与 显示设备的尺寸相比,要显得更长)
  1756. if (rcscale < fscale)
  1757. {
  1758. // Jeff.remarks
  1759. // 调整显示设备的大小,以使之能容纳图片尺寸;(即长宽比例上,要大于或等于图片的长宽比例)
  1760. // 所以有两种方法使得 rcscale >= fscale 表达式成立:
  1761. // -----------------------------------------------
  1762. // 方法1:显示设备宽加x值,计算出下面表达式x的值即可
  1763. // (rc.Width()+x) / rc.Height() >= width/height;
  1764. // 方法2:显示设备高减x值,计算出下面表达式x的值即可
  1765. // (rc.Width()) / (rc.Height()-x) >= width/height;
  1766. //------------------------------------------------
  1767. // 两种方法的最后表达式为:
  1768. // x >= rc.Height() - rcWidth()*(height/width);
  1769. // 即 x >= rc.Height() - rcWidth()/fscale;
  1770. //------------------------------------------------
  1771. dt = (rcwid - rchei*fscale) / 2;
  1772. rc.left += dt;
  1773. rc.right -= dt;
  1774. }
  1775. else
  1776. {
  1777. dt = (rchei - rcwid / fscale) / 2;
  1778. rc.top += dt;
  1779. rc.bottom -= dt;
  1780. }
  1781. }
  1782. catch (...)
  1783. {
  1784. }
  1785. }
  1786. void CNeroDlg::SaveImageToFile(__in Image *img, __in CString path)
  1787. {
  1788. try
  1789. {
  1790. if (img == NULL)
  1791. {
  1792. //printf("Jeff:img == NULL \n\n");
  1793. return;
  1794. }
  1795. CLSID encoderClsid;
  1796. BSTR bstr = path.AllocSysString();
  1797. path.MakeLower();
  1798. if (path.Right(3) == "bmp")
  1799. {
  1800. GetEncoderClsid(L"image/bmp", &encoderClsid);
  1801. img->Save(bstr, &encoderClsid, NULL);
  1802. }
  1803. else if (path.Right(3) == "png")
  1804. {
  1805. GetEncoderClsid(L"image/png", &encoderClsid);
  1806. img->Save(bstr, &encoderClsid, NULL);
  1807. }
  1808. else// if(path.Right (3)=="jpg")
  1809. {
  1810. GetEncoderClsid(L"image/jpeg", &encoderClsid);
  1811. EncoderParameters encoderParameters;
  1812. ULONG quality;
  1813. encoderParameters.Count = 1;
  1814. encoderParameters.Parameter[0].Guid = EncoderQuality;
  1815. encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
  1816. encoderParameters.Parameter[0].NumberOfValues = 1;
  1817. // Save the image as a JPEG with quality level 100.
  1818. quality = 100;
  1819. encoderParameters.Parameter[0].Value = &quality;
  1820. img->Save(bstr, &encoderClsid, &encoderParameters);
  1821. }
  1822. SysFreeString(bstr);
  1823. }
  1824. catch (...)
  1825. {
  1826. }
  1827. }
  1828. int CNeroDlg::GetEncoderClsid(__in const WCHAR* format, __inout CLSID* pClsid)
  1829. {
  1830. UINT num = 0; // number of image encoders
  1831. UINT size = 0; // size of the image encoder array in bytes
  1832. ImageCodecInfo* pImageCodecInfo = NULL;
  1833. GetImageEncodersSize(&num, &size);
  1834. if (size == 0)
  1835. return -1; // Failure
  1836. pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
  1837. if (pImageCodecInfo == NULL)
  1838. return -1; // Failure
  1839. GetImageEncoders(num, size, pImageCodecInfo);
  1840. for (UINT j = 0; j < num; ++j)
  1841. {
  1842. if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
  1843. {
  1844. *pClsid = pImageCodecInfo[j].Clsid;
  1845. free(pImageCodecInfo);
  1846. return j; // Success
  1847. }
  1848. }
  1849. free(pImageCodecInfo);
  1850. return -1; // FailureFailure
  1851. }