ShowCut.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. // ShowCut.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowCut.h"
  6. #include "JPEG.h"
  7. #include "MyLock.h"
  8. #include "ShowPhoto.h"
  9. #define THUMBNAIL_WIDTH 100
  10. #define THUMBNAIL_HEIGHT 90
  11. /////////////////////////////////////////////////////////////////////////////
  12. // ShowCut dialog IDC_BU Tdelall
  13. ShowCut::ShowCut(CWnd* pParent /*=NULL*/)
  14. : CDialog(ShowCut::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(ShowCut)
  17. //}}AFX_DATA_INIT
  18. m_bTerminate=false;
  19. m_bRunning=false;
  20. m_hThread = NULL;
  21. m_mode=0;
  22. }
  23. void ShowCut::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CDialog::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(ShowCut)
  27. DDX_Control(pDX, IDC_LIST1, m_List1);
  28. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(ShowCut, CDialog)
  32. //{{AFX_MSG_MAP(ShowCut)
  33. ON_WM_DESTROY()
  34. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  35. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  36. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // ShowCut message handlers
  41. BOOL ShowCut::OnInitDialog()
  42. {
  43. CDialog::OnInitDialog();
  44. CRect rc2;
  45. GetWindowRect(rc2);
  46. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  47. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  48. GetClientRect(rc2);
  49. if(m_mode==0)
  50. rc2.top +=35*g_fscaley;
  51. else
  52. {
  53. GetDlgItem(IDC_BUTdelall)->ShowWindow(0);
  54. GetDlgItem(IDC_BUTdel)->ShowWindow(0);
  55. GetDlgItem(IDOK)->ShowWindow(0);
  56. }
  57. m_List1.MoveWindow (rc2);
  58. int right=rc2.right ;
  59. GetDlgItem(IDOK)->GetWindowRect(rc2);
  60. ScreenToClient(rc2);
  61. int hei=rc2.Height ();
  62. int dtx=right-rc2.right-5 ;
  63. rc2.top =5;
  64. rc2.bottom =rc2.top +hei;
  65. rc2.left += dtx;
  66. rc2.right +=dtx;
  67. GetDlgItem(IDOK)->MoveWindow(rc2);
  68. GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
  69. ScreenToClient(rc2);
  70. rc2.top =5;
  71. rc2.bottom =rc2.top +hei;
  72. rc2.left += dtx;
  73. rc2.right +=dtx;
  74. GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
  75. GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
  76. ScreenToClient(rc2);
  77. rc2.top =5;
  78. rc2.bottom =rc2.top +hei;
  79. rc2.left += dtx;
  80. rc2.right +=dtx;
  81. GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
  82. if(GetSize()==0)
  83. {
  84. CDialog::OnCancel ();
  85. return 0;
  86. }
  87. if(g_bAllBranch)
  88. {
  89. CString branchpath=GetBranchPhotoPath(m_branch);
  90. m_path=g_path1+branchpath+"\\";
  91. }
  92. else
  93. m_path=g_path1+"\\";
  94. m_path+=m_id;
  95. m_path +="\\";
  96. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  97. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  98. LoadPhotos();
  99. return TRUE; // return TRUE unless you set the focus to a control
  100. // EXCEPTION: OCX Property Pages should return FALSE
  101. }
  102. unsigned __stdcall LoadThumbNail15(LPVOID lpParam)
  103. {
  104. try
  105. {
  106. ShowCut *pDlg=(ShowCut*)lpParam;
  107. CListCtrl *ListCtrl=&pDlg->m_List1;
  108. CImageList* pImgList=&pDlg->m_ImageListThumb;
  109. // reset our image list
  110. for(int i=0; i<pImgList->GetImageCount(); i++)
  111. pImgList->Remove(i);
  112. // remove all items from list view
  113. ListCtrl->DeleteAllItems();
  114. pImgList->SetImageCount(pDlg->m_vFileName.size());
  115. TCHAR path[MAX_PATH];
  116. vector<CString>::iterator iter;
  117. // Set redraw to FALSE to avoid flickering during adding new items
  118. ListCtrl->SetRedraw(FALSE);
  119. int nIndex=0;
  120. CString str, spath;
  121. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  122. {
  123. /* str=*iter;
  124. spath.Empty ();
  125. if(str.Left (str.ReverseFind ('\\')+1)!=pDlg->m_path)
  126. {
  127. spath=str.Left (str.ReverseFind ('\\')+1);
  128. spath= spath.Right (spath.GetLength ()-pDlg->m_path.GetLength ());
  129. }
  130. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  131. str=spath+str.Left (str.GetLength ()-4);*/
  132. ListCtrl->InsertItem(nIndex, pDlg->m_titlearray.ElementAt (nIndex), nIndex);
  133. // ListCtrl->InsertItem(nIndex, str, nIndex);
  134. }
  135. ListCtrl->SetRedraw(TRUE);
  136. ListCtrl->Invalidate();
  137. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  138. int XDest, YDest, nDestWidth, nDestHeight;
  139. nIndex=0;
  140. SolidBrush whitebrush(Color(255,255,255,255));
  141. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  142. {
  143. // Load Image File
  144. Image *image=NULL;
  145. Bitmap *pBmp=NULL;
  146. str=*iter;
  147. spath=str.Left (str.ReverseFind ('\\')+1);
  148. spath+="s";
  149. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  150. if(::CheckFileExist (spath))
  151. ::LoadImageFromBuf (&image, spath);
  152. else
  153. ::LoadImageFromBuf (&image, str);
  154. int orientation=GetOrientation(image);
  155. if(orientation==8)
  156. image->RotateFlip( Rotate270FlipNone );
  157. else if(orientation==6)
  158. image->RotateFlip( Rotate90FlipNone );
  159. if(image->GetWidth()==0)
  160. continue;
  161. // Calculate Rect to fit to canvas
  162. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  163. if(fImgRatio > fRatio)
  164. {
  165. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  166. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  167. YDest=0;
  168. nDestHeight=THUMBNAIL_HEIGHT;
  169. }
  170. else
  171. {
  172. XDest=0;
  173. nDestWidth=THUMBNAIL_WIDTH;
  174. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  175. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  176. }
  177. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  178. Graphics graph2(pBmp);
  179. graph2.Clear(Color(255,192,192,192));
  180. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  181. Graphics graph(pBmp);
  182. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  183. // Draw Image
  184. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  185. float scale=(float)nDestWidth/(float)image->GetWidth();
  186. int pos=pDlg->FindArray2 (pDlg->m_titlearray.ElementAt (nIndex) );
  187. if(pos!=-1)
  188. {
  189. int nIndex=pos;
  190. CRect rc=pDlg->m_rcarray.ElementAt (nIndex);
  191. int wid=pDlg->m_widtharray.ElementAt (nIndex).left;
  192. int hei=pDlg->m_widtharray.ElementAt (nIndex).top;
  193. scale*=(float)image->GetWidth()/(float)wid;
  194. rc.left *=scale;
  195. rc.right *=scale;
  196. rc.top *=scale;
  197. rc.bottom *=scale;
  198. rc.left +=XDest ;
  199. rc.right +=XDest;
  200. rc.top +=YDest ;
  201. rc.bottom +=YDest ;
  202. Pen blackPen(Color(255, 255, 0, 0), 1);
  203. graph.DrawRectangle(&blackPen, rc.left, rc.top, rc.Width (), rc.Height ());
  204. }
  205. delete image;
  206. // Attach to Bitmap and Replace image in CImageList
  207. CBitmap bitmap;
  208. HBITMAP hbmp;
  209. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  210. bitmap.Attach(hbmp);
  211. pImgList->Replace(nIndex, &bitmap, NULL);
  212. delete pBmp;
  213. // Redraw only a current item for removing flickering and fast speed.
  214. ListCtrl->RedrawItems(nIndex, nIndex);
  215. // Release used DC and Object
  216. }
  217. ListCtrl->Invalidate();
  218. pDlg->m_bRunning=false;
  219. pDlg->m_bTerminate=false;
  220. _endthreadex( 0 );
  221. return 0;
  222. }
  223. catch(...)
  224. {
  225. }
  226. }
  227. void ShowCut::LoadThumbImages()
  228. {
  229. TerminateThread();
  230. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail15,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  231. m_bRunning=true;
  232. }
  233. BOOL ShowCut::TerminateThread()
  234. {
  235. if ( !m_bRunning )
  236. return TRUE;
  237. m_bTerminate=true;
  238. for( ; ; )
  239. {
  240. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  241. break;
  242. MSG msg;
  243. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  244. {
  245. if (!AfxGetApp()->PumpMessage())
  246. break;
  247. }
  248. }
  249. ::CloseHandle(m_hThread);
  250. return TRUE;
  251. }
  252. void ShowCut::OnDestroy()
  253. {
  254. TerminateThread();
  255. CDialog::OnDestroy();
  256. // TODO: Add your message handler code here
  257. }
  258. void ShowCut::LoadPhotos()
  259. {
  260. if(m_bRunning)return;
  261. m_patharray1.RemoveAll ();
  262. m_path.MakeLower ();
  263. CStringArray dirarray;
  264. CString str,path2,no;
  265. if(1)
  266. {
  267. using namespace helper_coffs;
  268. ffsco o;
  269. o.dirs(1);
  270. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  271. ffsco::typeT coo;
  272. ffsco::typeT::iterator it;
  273. coo = o.co_dir();
  274. for (it = coo.begin();
  275. coo.end() != it;
  276. it ++)
  277. {
  278. str=(*it).c_str();
  279. str.MakeLower();
  280. if(str==m_path)continue;
  281. if(FindArray(&dirarray, str)==-1)
  282. {
  283. dirarray.Add (str);
  284. }
  285. }
  286. }
  287. if(1)
  288. {
  289. for(int i=0; i<dirarray.GetSize (); i++)
  290. {
  291. using namespace helper_coffs;
  292. ffsco o;
  293. o.dirs(1);
  294. o.find(LPCSTR(dirarray.ElementAt (i)), LPCSTR("*.jpg"));
  295. ffsco::typeT coo;
  296. ffsco::typeT::iterator it;
  297. coo = o.co_file();
  298. for (it = coo.begin();
  299. coo.end() != it;
  300. it ++)
  301. {
  302. str=(*it).c_str();
  303. if(str.GetAt (str.ReverseFind ('\\')+1)=='s')continue;
  304. if(str.GetAt (str.ReverseFind ('\\')+1)=='m')continue;
  305. str.MakeLower ();
  306. path2=str;
  307. path2.Replace ("客户原片", "修好的片");
  308. int pos1=path2.Find (m_id);
  309. pos1+=m_id.GetLength ();
  310. int pos2=path2.ReverseFind ('\\');
  311. path2=path2.Left (pos1)+path2.Right (path2.GetLength ()-pos2);
  312. no=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  313. no=no.Left (no.Find ("."));
  314. CStringArray noarray,namearray;
  315. noarray.Copy (m_noarray);
  316. namearray.Copy (m_namearray);
  317. int pos=::FindArray (&noarray, no);
  318. while(pos!=-1)
  319. {
  320. if(::PathFileExists (path2))
  321. {
  322. m_patharray1.Add (path2);
  323. }
  324. else
  325. {
  326. m_patharray1.Add (str);
  327. }
  328. m_titlearray.Add(no+"\r\n"+namearray.ElementAt (pos));
  329. noarray.RemoveAt (pos);namearray.RemoveAt (pos);
  330. pos=::FindArray (&noarray, no);
  331. }
  332. }
  333. }
  334. }
  335. if(m_patharray1.GetSize ()==0 && m_mode)
  336. {
  337. if(m_mode==2)
  338. AfxMessageBox("无照片裁剪!");
  339. CDialog::OnCancel ();
  340. return;
  341. }
  342. CStringArray *pArray=&m_patharray1;
  343. m_vFileName.clear();
  344. for(int i=0; i<pArray->GetSize (); i++)
  345. {
  346. CString filePath=pArray->ElementAt (i);
  347. filePath.MakeLower();
  348. m_vFileName.push_back(filePath);
  349. }
  350. LoadThumbImages();
  351. }
  352. void ShowCut::OnBUTdelall()
  353. {
  354. if(AfxMessageBox("清除裁剪后将无法恢复, 确认清除吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  355. CString sql;
  356. sql.Format ("update dindan set size='' where id='%s'", m_id);
  357. g_sendhead.bsql=1;
  358. if(m_branch!="" && g_bAllBranch)
  359. {
  360. g_branchip=GetIP(m_branch);
  361. g_pMainWnd->OnDisconnect();
  362. g_branchname=m_branch;
  363. g_bBranchModify=1;
  364. g_pMainWnd->ProcessChatMessageRequest2(sql);
  365. g_pMainWnd->OnDisconnect();g_bBranchModify=0;
  366. g_branchip=g_branchname="";
  367. }
  368. else
  369. g_pMainWnd->ProcessChatMessageRequest2(sql);
  370. if(g_bSendOK==0)return;
  371. AfxMessageBox("保存成功!");
  372. GetSize();
  373. LoadPhotos();
  374. }
  375. void ShowCut::OnBUTdel()
  376. {
  377. // TODO: Add your control notification handler code here
  378. POSITION pos;
  379. pos=m_List1.GetFirstSelectedItemPosition();
  380. if(pos==NULL)
  381. {
  382. AfxMessageBox("请先选中您要清除裁剪的照片!", MB_ICONINFORMATION);
  383. return;
  384. }
  385. if(AfxMessageBox("清除裁剪后将无法恢复, 确认清除吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  386. int iItem=m_List1.GetNextSelectedItem(pos);
  387. CString title = m_List1.GetItemText (iItem, 0);
  388. CString no=title.Left (title.Find ("\r"));
  389. CString name=title.Right (title.GetLength ()-title.ReverseFind ('\n')-1);
  390. {
  391. CString header=no+":"+name+",";
  392. int pos=m_size.Find (header);
  393. if(pos!=-1)
  394. {
  395. CString left,right;
  396. left=m_size.Left (pos);
  397. m_size=m_size.Right (m_size.GetLength ()-pos-header.GetLength ());
  398. pos=m_size.Find (";");
  399. right=m_size.Right (m_size.GetLength ()-pos-1);
  400. m_size=left+right;
  401. }
  402. }
  403. CString sql;
  404. sql.Format ("update dindan set size='%s' where id='%s'", m_size, m_id);
  405. g_sendhead.bsql=1;
  406. if(m_branch!="" && g_bAllBranch)
  407. {
  408. g_branchip=GetIP(m_branch);
  409. g_pMainWnd->OnDisconnect();
  410. g_branchname=m_branch;
  411. g_bBranchModify=1;
  412. g_pMainWnd->ProcessChatMessageRequest2(sql);
  413. g_pMainWnd->OnDisconnect();
  414. g_bBranchModify=0;
  415. g_branchip=g_branchname="";
  416. }
  417. else
  418. g_pMainWnd->ProcessChatMessageRequest2(sql);
  419. if(g_bSendOK==0)return;
  420. AfxMessageBox("保存成功!");
  421. GetSize();
  422. LoadPhotos();
  423. }
  424. void ShowCut::AddSize(CString size)
  425. {
  426. int pos=size.Find (":");
  427. if(pos!=-1)
  428. {
  429. CString str;
  430. CRect rc;
  431. str=size.Left (pos);
  432. m_noarray.Add (str);
  433. str=size.Right (size.GetLength ()-pos-1);
  434. pos=str.Find (",");
  435. m_namearray.Add(str.Left (pos));str.Delete (0, pos+1);
  436. pos=str.Find (",");
  437. rc.left=atoi(str.Left (pos));str.Delete (0, pos+1);
  438. pos=str.Find (",");
  439. rc.top=atoi(str.Left (pos));str.Delete (0, pos+1);
  440. m_widtharray.Add (rc);
  441. pos=str.Find (",");
  442. rc.left=atoi(str.Left (pos));str.Delete (0, pos+1);
  443. pos=str.Find (",");
  444. rc.top=atoi(str.Left (pos));str.Delete (0, pos+1);
  445. pos=str.Find (",");
  446. rc.right=atoi(str.Left (pos));str.Delete (0, pos+1);
  447. rc.bottom=atoi(str);
  448. m_rcarray.Add (rc);
  449. }
  450. }
  451. BOOL ShowCut::GetSize()
  452. {
  453. g_sendhead.bsql=0;
  454. g_sendhead.code[0]=11;
  455. g_sendhead.tabcount=1;
  456. CString filter="id='"+m_id+"';";
  457. if(m_branch!="")
  458. {
  459. g_branchip=GetIP(m_branch);
  460. g_pMainWnd->OnDisconnect();
  461. g_branchname=m_branch;
  462. g_bBranchModify=1;
  463. g_pMainWnd->ProcessChatMessageRequest2(filter);
  464. g_pMainWnd->OnDisconnect();
  465. g_bBranchModify=0;
  466. g_branchip=g_branchname="";
  467. }
  468. else
  469. g_pMainWnd->ProcessChatMessageRequest2(filter);
  470. if(g_bSendOK==0)
  471. {
  472. return 0;
  473. }
  474. CArray<CStringArray, CStringArray>m_List1array;
  475. DataToArray(&m_List1array);
  476. CenterWindow();
  477. m_noarray.RemoveAll();
  478. m_widtharray.RemoveAll();
  479. m_rcarray.RemoveAll();
  480. if( m_List1array.GetSize () )
  481. {
  482. m_size= m_List1array.ElementAt (0).ElementAt (60);//
  483. int pos=m_size.Find (";");
  484. while(pos!=-1)
  485. {
  486. AddSize(m_size.Left (pos));
  487. m_size=m_size.Right (m_size.GetLength ()-pos-1);
  488. pos=m_size.Find (";");
  489. }
  490. m_size= m_List1array.ElementAt (0).ElementAt (60);return 1;
  491. }
  492. return 0;
  493. }
  494. int ShowCut::FindArray2(CString title)
  495. {
  496. CString no=title.Left (title.Find ("\r"));
  497. CString name=title.Right (title.GetLength ()-title.ReverseFind ('\n')-1);
  498. for(int i=0; i<m_noarray.GetSize (); i++)
  499. {
  500. if(no==m_noarray.ElementAt (i) && name==m_namearray.ElementAt (i))
  501. return i;
  502. }
  503. return -1;
  504. }
  505. void ShowCut::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  506. {
  507. // TODO: Add your control notification handler code here
  508. POSITION pos;
  509. pos=m_List1.GetFirstSelectedItemPosition();
  510. if(pos==NULL)
  511. {
  512. return;
  513. }
  514. int iItem=m_List1.GetNextSelectedItem(pos);
  515. Image *image=NULL;
  516. if(m_patharray1.GetSize()<=iItem)return;
  517. CString str=m_patharray1.ElementAt(iItem);
  518. ::LoadImageFromBuf (&image, str);
  519. int orientation=GetOrientation(image);
  520. if(orientation==8)
  521. image->RotateFlip( Rotate270FlipNone );
  522. else if(orientation==6)
  523. image->RotateFlip( Rotate90FlipNone );
  524. if(image->GetWidth()==0)
  525. return;
  526. Graphics graph(image);
  527. // Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  528. // Draw Image
  529. // graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  530. float scale=1.0;//(float)nDestWidth/(float)image->GetWidth();
  531. int pos2=FindArray2 (m_titlearray.ElementAt (iItem) );
  532. if(pos2!=-1)
  533. {
  534. int nIndex=pos2;
  535. CRect rc=m_rcarray.ElementAt (nIndex);
  536. int wid=m_widtharray.ElementAt (nIndex).left;
  537. int hei=m_widtharray.ElementAt (nIndex).top;
  538. scale*=(float)image->GetWidth()/(float)wid;
  539. rc.left *=scale;
  540. rc.right *=scale;
  541. rc.top *=scale;
  542. rc.bottom *=scale;
  543. /* rc.left +=XDest ;
  544. rc.right +=XDest;
  545. rc.top +=YDest ;
  546. rc.bottom +=YDest ;*/
  547. Pen blackPen(Color(255, 255, 0, 0), 1);
  548. graph.DrawRectangle(&blackPen, rc.left, rc.top, rc.Width (), rc.Height ());
  549. ShowPhoto dlg;
  550. dlg.m_pImg=image;
  551. dlg.DoModal();
  552. }
  553. delete image;
  554. *pResult = 0;
  555. }