ShowEffect.cpp 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. // ShowEffectDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowEffect.h"
  6. #include <math.h>
  7. #include "InputName.h"
  8. #define THUMBNAIL_WIDTH 60
  9. #define THUMBNAIL_HEIGHT 50
  10. /////////////////////////////////////////////////////////////////////////////
  11. // ShowEffectDlg dialog
  12. ShowEffectDlg::ShowEffectDlg(CWnd* pParent /*=NULL*/)
  13. : CDialog(ShowEffectDlg::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(ShowEffectDlg)
  16. // NOTE: the ClassWizard will add member initialization here
  17. m_pbmp=NULL;
  18. m_pImage=NULL;
  19. m_pImagebak=NULL;
  20. m_pPhoto=NULL;
  21. //}}AFX_DATA_INIT
  22. m_effectpos=0;
  23. m_photopos=0;
  24. m_fscale=1.0;
  25. m_bTerminate=false;
  26. m_bRunning=false;
  27. m_hThread = NULL;
  28. m_bTerminate2=false;
  29. m_bRunning2=false;
  30. m_hThread2 = NULL;
  31. m_bLoadEffect=1;
  32. m_bLoadPhoto=1;
  33. }
  34. void ShowEffectDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(ShowEffectDlg)
  38. DDX_Control(pDX, IDC_LIST2, m_List2);
  39. DDX_Control(pDX, IDC_LIST1, m_List1);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(ShowEffectDlg, CDialog)
  43. //{{AFX_MSG_MAP(ShowEffectDlg)
  44. ON_WM_DESTROY()
  45. ON_WM_PAINT()
  46. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  47. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  48. ON_WM_LBUTTONDOWN()
  49. ON_WM_MOUSEMOVE()
  50. ON_WM_LBUTTONUP()
  51. ON_WM_MOUSEWHEEL()
  52. ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
  53. ON_WM_TIMER()
  54. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. // ON_WM_ERASEBKGND()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // ShowEffectDlg message handlers
  60. unsigned __stdcall LoadThumbNail17(LPVOID lpParam)
  61. {
  62. try
  63. {
  64. ShowEffectDlg *pDlg=(ShowEffectDlg*)lpParam;
  65. CListCtrl *ListCtrl=&pDlg->m_List2;
  66. CImageList* pImgList=&pDlg->m_ImageListThumb2;
  67. // reset our image list
  68. for(int i=0; i<pImgList->GetImageCount(); i++)
  69. pImgList->Remove(i);
  70. // remove all items from list view
  71. ListCtrl->DeleteAllItems();
  72. pImgList->SetImageCount(pDlg->m_vFileName2.size());
  73. TCHAR path[MAX_PATH];
  74. vector<CString>::iterator iter;
  75. // Set redraw to FALSE to avoid flickering during adding new items
  76. ListCtrl->SetRedraw(FALSE);
  77. int nIndex=0;
  78. CString str, spath;
  79. for(iter=pDlg->m_vFileName2.begin(); iter!=pDlg->m_vFileName2.end() && pDlg->m_bTerminate2!=true; iter++, nIndex++)
  80. {
  81. str=*iter;
  82. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  83. str=str.Left (str.Find ("."));
  84. ListCtrl->InsertItem(nIndex, str, nIndex);
  85. }
  86. ListCtrl->SetRedraw(TRUE);
  87. ListCtrl->Invalidate();
  88. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  89. int XDest, YDest, nDestWidth, nDestHeight;
  90. nIndex=0;
  91. SolidBrush whitebrush(Color(255,255,255,255));
  92. for(iter=pDlg->m_vFileName2.begin(); iter!=pDlg->m_vFileName2.end() && pDlg->m_bTerminate2!=true; iter++, nIndex++)
  93. {
  94. // Load Image File
  95. Image *image=NULL;
  96. Bitmap *pBmp=NULL;
  97. str=*iter;
  98. spath=str.Left (str.ReverseFind ('\\')+1);
  99. spath+="s";
  100. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  101. if(::CheckFileExist (spath))
  102. ::LoadImageFromBuf (&image, spath);
  103. else
  104. ::LoadImageFromBuf (&image, str);
  105. int orientation=GetOrientation(image);
  106. if(orientation==8)
  107. image->RotateFlip( Rotate270FlipNone );
  108. else if(orientation==6)
  109. image->RotateFlip( Rotate90FlipNone );
  110. if(image->GetWidth()==0)
  111. continue;
  112. // Calculate Rect to fit to canvas
  113. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  114. if(fImgRatio > fRatio)
  115. {
  116. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  117. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  118. YDest=0;
  119. nDestHeight=THUMBNAIL_HEIGHT;
  120. }
  121. else
  122. {
  123. XDest=0;
  124. nDestWidth=THUMBNAIL_WIDTH;
  125. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  126. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  127. }
  128. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  129. Graphics graph2(pBmp);
  130. graph2.Clear(Color(255,192,192,192));
  131. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  132. Graphics graph(pBmp);
  133. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  134. // Draw Image
  135. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  136. delete image;
  137. // Attach to Bitmap and Replace image in CImageList
  138. CBitmap bitmap;
  139. HBITMAP hbmp;
  140. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  141. bitmap.Attach(hbmp);
  142. pImgList->Replace(nIndex, &bitmap, NULL);
  143. delete pBmp;
  144. // Redraw only a current item for removing flickering and fast speed.
  145. ListCtrl->RedrawItems(nIndex, nIndex);
  146. // Release used DC and Object
  147. }
  148. ListCtrl->Invalidate();
  149. pDlg->m_bRunning2=false;
  150. pDlg->m_bTerminate2=false;
  151. _endthreadex( 0 );
  152. return 0;
  153. }
  154. catch(...)
  155. {
  156. }
  157. }
  158. unsigned __stdcall LoadThumbNail16(LPVOID lpParam)
  159. {
  160. try
  161. {
  162. ShowEffectDlg *pDlg=(ShowEffectDlg*)lpParam;
  163. CListCtrl *ListCtrl=&pDlg->m_List1;
  164. CImageList* pImgList=&pDlg->m_ImageListThumb;
  165. // reset our image list
  166. for(int i=0; i<pImgList->GetImageCount(); i++)
  167. pImgList->Remove(i);
  168. // remove all items from list view
  169. ListCtrl->DeleteAllItems();
  170. pImgList->SetImageCount(pDlg->m_vFileName.size());
  171. TCHAR path[MAX_PATH];
  172. vector<CString>::iterator iter;
  173. // Set redraw to FALSE to avoid flickering during adding new items
  174. ListCtrl->SetRedraw(FALSE);
  175. int nIndex=0;
  176. CString str, spath;
  177. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  178. {
  179. str=*iter;
  180. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  181. str=str.Left (str.Find ("."));
  182. ListCtrl->InsertItem(nIndex, str, nIndex);
  183. }
  184. ListCtrl->SetRedraw(TRUE);
  185. ListCtrl->Invalidate();
  186. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  187. int XDest, YDest, nDestWidth, nDestHeight;
  188. nIndex=0;
  189. SolidBrush whitebrush(Color(255,255,255,255));
  190. for(iter=pDlg->m_vFileName.begin(); iter!=pDlg->m_vFileName.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  191. {
  192. // Load Image File
  193. Image *image=NULL;
  194. Bitmap *pBmp=NULL;
  195. str=*iter;
  196. spath=str.Left (str.ReverseFind ('\\')+1);
  197. spath+="s";
  198. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  199. spath.Replace ("png","jpg");
  200. if(::CheckFileExist (spath))
  201. {
  202. ::LoadImageFromBuf (&image, spath);
  203. }
  204. else
  205. ::LoadImageFromBuf (&image, str);
  206. int orientation=GetOrientation(image);
  207. if(orientation==8)
  208. image->RotateFlip( Rotate270FlipNone );
  209. else if(orientation==6)
  210. image->RotateFlip( Rotate90FlipNone );
  211. if(image->GetWidth()==0)
  212. continue;
  213. // Calculate Rect to fit to canvas
  214. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  215. if(fImgRatio > fRatio)
  216. {
  217. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  218. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  219. YDest=0;
  220. nDestHeight=THUMBNAIL_HEIGHT;
  221. }
  222. else
  223. {
  224. XDest=0;
  225. nDestWidth=THUMBNAIL_WIDTH;
  226. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  227. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  228. }
  229. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  230. Graphics graph2(pBmp);
  231. graph2.Clear(Color(255,192,192,192));
  232. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  233. Graphics graph(pBmp);
  234. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  235. // Draw Image
  236. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  237. delete image;
  238. // Attach to Bitmap and Replace image in CImageList
  239. CBitmap bitmap;
  240. HBITMAP hbmp;
  241. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  242. bitmap.Attach(hbmp);
  243. pImgList->Replace(nIndex, &bitmap, NULL);
  244. delete pBmp;
  245. // Redraw only a current item for removing flickering and fast speed.
  246. ListCtrl->RedrawItems(nIndex, nIndex);
  247. // Release used DC and Object
  248. }
  249. ListCtrl->Invalidate();
  250. pDlg->m_bRunning=false;
  251. pDlg->m_bTerminate=false;
  252. _endthreadex( 0 );
  253. return 0;
  254. }
  255. catch(...)
  256. {
  257. }
  258. }
  259. BOOL ShowEffectDlg::OnInitDialog()
  260. {
  261. CDialog::OnInitDialog();
  262. GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(49));
  263. using namespace helper_coffs;
  264. ffsco o;
  265. o.dirs(0);
  266. o.find(LPCSTR(g_path7), LPCSTR("*.png"));
  267. ffsco::typeT coo;
  268. ffsco::typeT::iterator it;
  269. coo = o.co_file();
  270. for (it = coo.begin();
  271. coo.end() != it;
  272. it ++)
  273. {
  274. m_effectpatharray.Add ((*it).c_str());
  275. }
  276. if(m_effectpatharray.GetSize()==0)
  277. {
  278. AfxMessageBox("您还没有安装效果图!", MB_ICONINFORMATION);
  279. ::CreateDirectory (g_path7, NULL);
  280. // CDialog::OnCancel ();
  281. // return false;
  282. }
  283. // TODO: Add extra initialization here
  284. ::SetWindowPos(m_hWnd,HWND_TOP,0 ,0,g_screenwid,g_screenhei,SWP_SHOWWINDOW);
  285. m_rcscreen=CRect(0, 0, g_screenwid, g_screenhei);
  286. CRect rc,rc2,rc3;
  287. GetClientRect(rc2);
  288. GetDlgItem(IDC_BUTTON1)->GetWindowRect(rc3);
  289. ScreenToClient(rc3);
  290. rc=rc2;
  291. rc.right =110;
  292. rc.top =rc3.bottom +rc3.top;
  293. m_List1.MoveWindow(rc);
  294. rc=rc2;
  295. rc.left=rc.right-110;
  296. m_List2.MoveWindow(rc);
  297. rc=rc2;
  298. rc.left +=110;
  299. rc.right -=110;
  300. m_pbmp=new Bitmap(rc.Width (), rc.Height (), PixelFormat24bppRGB );
  301. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  302. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  303. m_ImageListThumb2.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  304. m_List2.SetImageList(&m_ImageListThumb2, LVSIL_NORMAL);
  305. if(m_bRunning)return 0;
  306. CStringArray *pArray=&m_effectpatharray;
  307. m_vFileName.clear();
  308. for(int i=0; i<pArray->GetSize (); i++)
  309. {
  310. CString filePath=pArray->ElementAt (i);
  311. filePath.MakeLower();
  312. m_vFileName.push_back(filePath);
  313. }
  314. TerminateThread();
  315. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail16,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  316. m_bRunning=true;
  317. {
  318. if(m_bRunning2)return 0;
  319. CStringArray *pArray=m_pPhotopatharray;
  320. m_vFileName2.clear();
  321. for(int i=0; i<pArray->GetSize (); i++)
  322. {
  323. CString filePath=pArray->ElementAt (i);
  324. filePath.MakeLower();
  325. m_vFileName2.push_back(filePath);
  326. }
  327. TerminateThread2();
  328. m_hThread2 = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail17,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID2);
  329. m_bRunning2=true;
  330. }
  331. SetTimer(1, 200, NULL);
  332. return TRUE; // return TRUE unless you set the focus to a control
  333. // EXCEPTION: OCX Property Pages should return FALSE
  334. }
  335. BOOL ShowEffectDlg::TerminateThread()
  336. {
  337. if ( !m_bRunning )
  338. return TRUE;
  339. m_bTerminate=true;
  340. for( ; ; )
  341. {
  342. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  343. break;
  344. MSG msg;
  345. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  346. {
  347. if (!AfxGetApp()->PumpMessage())
  348. break;
  349. }
  350. }
  351. ::CloseHandle(m_hThread);
  352. return TRUE;
  353. }
  354. BOOL ShowEffectDlg::TerminateThread2()
  355. {
  356. if ( !m_bRunning2 )
  357. return TRUE;
  358. m_bTerminate2=true;
  359. for( ; ; )
  360. {
  361. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  362. break;
  363. MSG msg;
  364. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  365. {
  366. if (!AfxGetApp()->PumpMessage())
  367. break;
  368. }
  369. }
  370. ::CloseHandle(m_hThread2);
  371. return TRUE;
  372. }
  373. void ShowEffectDlg::OnDestroy()
  374. {
  375. // TODO: Add your message handler code here
  376. TerminateThread2();
  377. TerminateThread();
  378. if(m_pbmp) delete m_pbmp;m_pbmp=NULL;
  379. if(m_pImage)delete m_pImage;m_pImage=NULL;
  380. if(m_pImagebak)delete m_pImagebak;m_pImagebak=NULL;
  381. if(m_pPhoto)delete m_pPhoto;m_pPhoto=NULL;
  382. CDialog::OnDestroy();
  383. }
  384. void ShowEffectDlg::OnPaint()
  385. {
  386. CPaintDC dc(this); // device context for painting
  387. // TODO: Add your message handler code here
  388. try
  389. {
  390. if(m_pbmp)
  391. {
  392. Graphics graph2(dc.GetSafeHdc ());
  393. graph2.DrawImage(m_pbmp,110,0);
  394. }
  395. }
  396. catch(...)
  397. {
  398. }
  399. // Do not call CDialog::OnPaint() for painting messages
  400. }
  401. BOOL ShowEffectDlg::OnEraseBkgnd(CDC* pDC)
  402. {
  403. // TODO: Add your message handler code here and/or call default
  404. return 1;
  405. }
  406. void ShowEffectDlg::InitRc(Image *img)
  407. {
  408. try
  409. {
  410. if(img==NULL)return;
  411. CRect rc;
  412. GetClientRect(rc);
  413. rc.right -=220;
  414. m_rc=rc;
  415. int width,height;
  416. width=img->GetWidth();
  417. height=img->GetHeight();
  418. //////////
  419. float fscale=(float)width/(float)height;
  420. float rcscale=((float)m_rc.Width ())/((float)m_rc.Height ());
  421. int rcwid=m_rc.Width ();
  422. int rchei=m_rc.Height ();
  423. int dt=0;
  424. if(rcscale<fscale)
  425. {
  426. dt=(rchei-rcwid/fscale)/2;
  427. m_rc.top+=dt;
  428. m_rc.bottom-=dt;
  429. }
  430. else
  431. {
  432. dt=(rcwid-rchei*fscale)/2;
  433. m_rc.left +=dt;
  434. m_rc.right-=dt;
  435. }
  436. m_rcbak=m_rc;
  437. }
  438. catch(...)
  439. {
  440. }
  441. }
  442. void ShowEffectDlg::RcChange()
  443. {
  444. }
  445. int GetFileNo2()
  446. {
  447. CString path;
  448. int begin=1;
  449. path.Format ("%s\\效果图-%d.png", g_path7, begin);
  450. while(::CheckFileExist (path))
  451. {
  452. begin++;
  453. path.Format ("%s\\效果图-%d.png", g_path7, begin);
  454. }
  455. return begin;
  456. }
  457. void ShowEffectDlg::OnButton1()
  458. {
  459. if(AfxMessageBox("制作方法:\r\n1.图片格式为透明PNG格式.\r\n2.显示客照的位置为透明.", MB_ICONINFORMATION));
  460. CFileDialog fdlg(true, NULL,"openfile", OFN_ALLOWMULTISELECT,"png文件(*.png)|*.png||");
  461. TCHAR szBuffer[60000]={0};
  462. fdlg.m_ofn.lpstrFile = szBuffer;
  463. fdlg.m_ofn.nMaxFile = 60000;
  464. if(fdlg.DoModal ()!=IDOK)
  465. {
  466. return;
  467. }
  468. POSITION pos=fdlg.GetStartPosition ();
  469. CStringArray array;
  470. while(pos!=NULL)
  471. {
  472. array.Add(fdlg.GetNextPathName (pos));
  473. }
  474. if(array.GetSize ()==0)return;
  475. int i = 0;
  476. for( i=0; i<array.GetSize (); i++)
  477. {
  478. Bitmap *img=NULL;
  479. ::LoadImageFromBuf (&img, array.ElementAt (i));
  480. if(img==NULL)continue;
  481. if(img->GetWidth()==0)continue;
  482. if(img->GetWidth()>2000 || img->GetHeight()>2000)
  483. {
  484. CRect rc(0,0,2000,2000);
  485. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  486. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  487. Graphics graphic(simg);graphic.Clear(Color(0,0,0,0));
  488. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  489. delete img;
  490. img=simg;
  491. }
  492. CString path;
  493. CString str=array.ElementAt (i);
  494. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  495. str=str.Left (str.Find ("."));
  496. /* InputName dlg;
  497. if(dlg.DoModal ()!=IDOK)
  498. {
  499. path.Format ("%s\\效果图-%d.png", g_path7, GetFileNo2());
  500. }
  501. else
  502. { */
  503. path.Format ("%s\\%s.png", g_path7, str);
  504. //}
  505. ::SaveImageToFile (img, path);
  506. str=path;
  507. CString spath=str.Left (str.ReverseFind ('\\')+1);
  508. spath+="s";
  509. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  510. spath.Replace ("png","jpg");
  511. CRect rc(0,0,100,100);
  512. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  513. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  514. Graphics graphic(simg);graphic.Clear(Color(0,0,0,0));
  515. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  516. ::SaveImageToFile (simg, spath);
  517. delete img;delete simg;
  518. }
  519. m_effectpos=0;
  520. m_photopos=0;
  521. m_effectpatharray.RemoveAll ();
  522. using namespace helper_coffs;
  523. ffsco o;
  524. o.dirs(0);
  525. o.find(LPCSTR(g_path7), LPCSTR("*.png"));
  526. ffsco::typeT coo;
  527. ffsco::typeT::iterator it;
  528. coo = o.co_file();
  529. for (it = coo.begin();coo.end() != it;it ++)
  530. {
  531. m_effectpatharray.Add ((*it).c_str());
  532. }
  533. if(m_effectpatharray.GetSize()==0)
  534. {
  535. AfxMessageBox("您还没有安装效果图!", MB_ICONINFORMATION);
  536. ::CreateDirectory (g_path7, NULL);
  537. }
  538. TerminateThread();
  539. CStringArray *pArray=&m_effectpatharray;
  540. m_vFileName.clear();
  541. for( i=0; i<pArray->GetSize (); i++)
  542. {
  543. CString filePath=pArray->ElementAt (i);
  544. filePath.MakeLower();
  545. m_vFileName.push_back(filePath);
  546. }
  547. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail16,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  548. m_bRunning=true;
  549. }
  550. void ShowEffectDlg::OnButton2()
  551. {
  552. POSITION pos;
  553. pos=m_List1.GetFirstSelectedItemPosition();
  554. if(pos==NULL)
  555. {
  556. return;
  557. }
  558. int selpos=m_List1.GetNextSelectedItem(pos);
  559. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  560. CString str=m_effectpatharray.ElementAt (selpos);
  561. CString spath=str.Left (str.ReverseFind ('\\')+1);
  562. spath+="s";
  563. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  564. spath.Replace ("png","jpg");
  565. ::DeleteFile (str);
  566. ::DeleteFile(spath);
  567. m_effectpatharray.RemoveAt (selpos);
  568. m_List1.DeleteItem (selpos); m_effectpos=0;
  569. m_photopos=0;
  570. }
  571. void ShowEffectDlg::OnLButtonDown(UINT nFlags, CPoint point)
  572. {
  573. // TODO: Add your message handler code here and/or call default
  574. // SetCapture();
  575. // m_startpt=point;
  576. CDialog::OnLButtonDown(nFlags, point);
  577. }
  578. void ShowEffectDlg::OnMouseMove(UINT nFlags, CPoint point)
  579. {
  580. // TODO: Add your message handler code here and/or call default
  581. /* if(GetCapture()!=this)return;
  582. if(m_rc.Width ()>m_rcscreen.Width ())
  583. {
  584. if(m_rc.left <m_rcscreen.left && point.x>m_startpt.x)
  585. {
  586. int dt=min(point.x-m_startpt.x, m_rcscreen.left-m_rc.left);
  587. m_rc.left +=dt;
  588. m_rc.right +=dt;
  589. }
  590. else if(m_rc.right >m_rcscreen.right && point.x<m_startpt.x)
  591. {
  592. int dt=min(m_startpt.x-point.x, m_rc.right-m_rcscreen.right);
  593. m_rc.left -=dt;
  594. m_rc.right -=dt;
  595. }
  596. }
  597. if(m_rc.Height ()>m_rcscreen.Height ())
  598. {
  599. if(m_rc.top <m_rcscreen.top && point.y>m_startpt.y)
  600. {
  601. int dt=min(point.y-m_startpt.y, m_rcscreen.top-m_rc.top);
  602. m_rc.top +=dt;
  603. m_rc.bottom +=dt;
  604. }
  605. else if(m_rc.bottom >m_rcscreen.bottom && point.y<m_startpt.y)
  606. {
  607. int dt=min(m_startpt.y-point.y, m_rc.bottom-m_rcscreen.bottom);
  608. m_rc.top -=dt;
  609. m_rc.bottom -=dt;
  610. }
  611. }
  612. m_startpt=point;
  613. RcChange();*/
  614. CDialog::OnMouseMove(nFlags, point);
  615. }
  616. void ShowEffectDlg::OnLButtonUp(UINT nFlags, CPoint point)
  617. {
  618. // TODO: Add your message handler code here and/or call default
  619. /* if(GetCapture()!=this)return;
  620. ReleaseCapture();*/
  621. CDialog::OnLButtonUp(nFlags, point);
  622. }
  623. BOOL ShowEffectDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  624. {
  625. // TODO: Add your message handler code here and/or call default
  626. /* if(m_pImage==NULL)return 1;
  627. if(zDelta>0)
  628. {
  629. m_fscale*=1.2;
  630. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  631. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  632. m_rc.left -=dtx;
  633. m_rc.right +=dtx;
  634. m_rc.top -=dty;
  635. m_rc.bottom +=dty;
  636. }
  637. else
  638. {
  639. if(m_fscale<=1)return 1;
  640. m_fscale/=1.2;
  641. if(m_fscale<1)m_fscale=1;
  642. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  643. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  644. m_rc.left -=dtx;
  645. m_rc.right +=dtx;
  646. m_rc.top -=dty;
  647. m_rc.bottom +=dty;
  648. if(m_rcbak.Height ()==m_rcscreen.Height ())
  649. {
  650. if(m_rc.top <m_rcscreen.top && m_rc.bottom < m_rcscreen.bottom )
  651. {
  652. dtx=m_rcscreen.bottom -m_rc.bottom;
  653. m_rc.top +=dtx;
  654. m_rc.bottom +=dtx;
  655. }
  656. else if(m_rc.top >m_rcscreen.top && m_rc.bottom > m_rcscreen.bottom )
  657. {
  658. dtx=m_rc.top-m_rcscreen.top;
  659. m_rc.top -=dtx;
  660. m_rc.bottom -=dtx;
  661. }
  662. dtx=m_rc.Width ();
  663. m_rc.left =(m_rcscreen.Width ()-dtx)/2;
  664. m_rc.right =m_rc.left +dtx;
  665. }
  666. if(m_rcbak.Width ()==m_rcscreen.Width ())
  667. {
  668. if(m_rc.left <m_rcscreen.left && m_rc.right < m_rcscreen.right )
  669. {
  670. dtx=m_rcscreen.right -m_rc.right;
  671. m_rc.left +=dtx;
  672. m_rc.right +=dtx;
  673. }
  674. else if(m_rc.left >m_rcscreen.left && m_rc.right > m_rcscreen.right )
  675. {
  676. dtx=m_rc.left-m_rcscreen.left;
  677. m_rc.left -=dtx;
  678. m_rc.right -=dtx;
  679. }
  680. dtx=m_rc.Height ();
  681. m_rc.top =(m_rcscreen.Height ()-dtx)/2;
  682. m_rc.bottom =m_rc.top +dtx;
  683. }
  684. }
  685. RcChange();*/
  686. return CDialog::OnMouseWheel(nFlags, zDelta, pt);
  687. }
  688. void ShowEffectDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  689. {
  690. // TODO: Add your control notification handler code here
  691. POSITION pos;
  692. pos=m_List1.GetFirstSelectedItemPosition();
  693. if(pos==NULL)
  694. {
  695. return;
  696. }
  697. m_effectpos=m_List1.GetNextSelectedItem(pos);m_bLoadEffect=1;
  698. MakeEffect();
  699. *pResult = 0;
  700. }
  701. void ShowEffectDlg::OnTimer(UINT nIDEvent)
  702. {
  703. // TODO: Add your message handler code here and/or call default
  704. KillTimer(nIDEvent);
  705. MakeEffect();
  706. }
  707. void ShowEffectDlg::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  708. {
  709. // TODO: Add your control notification handler code here
  710. POSITION pos;
  711. pos=m_List2.GetFirstSelectedItemPosition();
  712. if(pos==NULL)
  713. {
  714. return;
  715. }
  716. m_photopos=m_List2.GetNextSelectedItem(pos); m_bLoadPhoto=1;
  717. MakeEffect();
  718. *pResult = 0;
  719. }
  720. int GetLengFromPt(CPoint pt1, CPoint pt2)
  721. {
  722. return (pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y);
  723. }
  724. int GetLengFromPt2(CPoint pt1, CPoint pt2)
  725. {
  726. return sqrt((float)(pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
  727. }
  728. void ShowEffectDlg::MakeEffect()
  729. {
  730. if(m_effectpatharray.GetSize()==0)return;
  731. Graphics graph(m_pbmp);
  732. graph.Clear(Color(255,255,255,255));
  733. if(m_bLoadPhoto)
  734. {
  735. if(m_pPhoto)delete m_pPhoto;m_pPhoto=NULL;
  736. }
  737. if(m_bLoadEffect)
  738. {
  739. if(m_pImage)delete m_pImage;m_pImage=NULL;
  740. if(m_pImagebak)delete m_pImagebak;m_pImagebak=NULL;
  741. ::LoadImageFromBuf (&m_pImage, m_effectpatharray.ElementAt (m_effectpos));
  742. if(m_pPhotopatharray->GetSize ())GetRgn(m_pImage);
  743. m_pImagebak=m_pImage->Clone(0,0,m_pImage->GetWidth(),m_pImage->GetHeight(),PixelFormat32bppARGB );
  744. }
  745. int width,height;
  746. width=m_pImage->GetWidth();
  747. height=m_pImage->GetHeight();
  748. if(width==0 || height==0)return;
  749. InitRc(m_pImage);
  750. CPoint pt1,pt2,pt3;
  751. int leng1,leng2,leng3;
  752. CPoint curpt;
  753. int leng;
  754. Graphics graph2(m_pImage);
  755. if(m_pPhotopatharray->GetSize ())
  756. {
  757. if(m_bLoadPhoto)
  758. ::LoadImageFromBuf (&m_pPhoto, m_pPhotopatharray->ElementAt (m_photopos));
  759. int i;
  760. for(int aa=0; aa<RCARRARCOUNT; aa++)
  761. {
  762. leng1=leng2=leng3=10000000;
  763. for( i=0; i<m_rcarray[aa].GetSize (); i+=2)
  764. {
  765. curpt.x=m_rcarray[aa].ElementAt (i);
  766. curpt.y=m_rcarray[aa].ElementAt (i+1);
  767. leng=GetLengFromPt(CPoint(0,0), curpt);
  768. if(leng<leng1)
  769. {
  770. leng1=leng;
  771. pt1=curpt;
  772. }
  773. leng=GetLengFromPt(CPoint(m_pImage->GetWidth(),0), curpt);
  774. if(leng<leng2)
  775. {
  776. leng2=leng;
  777. pt2=curpt;
  778. }
  779. leng=GetLengFromPt(CPoint(0,m_pImage->GetHeight()), curpt);
  780. if(leng<leng3)
  781. {
  782. leng3=leng;
  783. pt3=curpt;
  784. }
  785. }
  786. if(m_rcarray[aa].GetSize ())
  787. {
  788. pt1.x*=m_tempscale;
  789. pt1.y*=m_tempscale;
  790. pt2.x*=m_tempscale;
  791. pt2.y*=m_tempscale;
  792. pt3.x*=m_tempscale;
  793. pt3.y*=m_tempscale;
  794. Point destinationPoints[] = {
  795. Point(pt1.x, pt1.y), // destination for upper-left point of original
  796. Point(pt2.x, pt2.y), // destination for upper-right point of original
  797. Point(pt3.x, pt3.y)}; // destination for lower-left point of original
  798. // graph2.DrawImage(m_pPhoto, destinationPoints, 3);
  799. int lengx=GetLengFromPt2(pt1, pt2);
  800. int lengy=GetLengFromPt2(pt1, pt3);
  801. /* CString ss;
  802. ss.Format("pt1:%d,%d pt2:%d,%d leng:%d", pt1.x, pt1.y,pt2.x, pt2.y,lengx);
  803. AfxMessageBox(ss);
  804. ss.Format("pt1:%d,%d pt3:%d,%d leng:%d", pt1.x, pt1.y,pt3.x, pt3.y,lengy);
  805. AfxMessageBox(ss);*/
  806. CRect rc(0,0,m_pPhoto->GetWidth(),m_pPhoto->GetHeight());
  807. RectFitDes(lengx,lengy,rc);
  808. graph2.DrawImage(
  809. m_pPhoto,
  810. destinationPoints,
  811. 3,
  812. rc.left,
  813. rc.top,
  814. rc.Width(),
  815. rc.Height(),
  816. UnitPixel,
  817. NULL,
  818. NULL,
  819. NULL);
  820. }
  821. }
  822. ///////
  823. graph2.DrawImage(m_pImagebak, 0, 0);
  824. }
  825. Rect destinationRect( m_rc.left , m_rc.top , m_rc.Width (), m_rc.Height () );
  826. graph.DrawImage(m_pImage, destinationRect, 0,0,width,height,UnitPixel);
  827. CRect rc;
  828. GetClientRect(rc);
  829. rc.left +=110;
  830. rc.right -=110;
  831. InvalidateRect(rc);
  832. m_bLoadEffect=0;
  833. m_bLoadPhoto=0;
  834. }
  835. void ShowEffectDlg::GetRgn(Bitmap *pBmpImage2)
  836. {
  837. m_tempscale=1.0;
  838. if(pBmpImage2==NULL)return;
  839. Bitmap *pBmpImage=NULL;
  840. BOOL bdelete=0;
  841. if(pBmpImage2->GetWidth()>800 || pBmpImage2->GetHeight()>800)
  842. {
  843. bdelete=1;
  844. CRect rc(0,0,800,800);
  845. RectFitDes(pBmpImage2->GetWidth(), pBmpImage2->GetHeight(), rc);
  846. pBmpImage=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  847. Graphics graphic(pBmpImage);graphic.Clear(Color(0,0,0,0));
  848. graphic.DrawImage(pBmpImage2, 0,0,pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  849. m_tempscale=(float)pBmpImage2->GetWidth()/(float)pBmpImage->GetWidth();
  850. }
  851. else
  852. pBmpImage=pBmpImage2;
  853. BitmapData bitmapData;
  854. UINT* pixels;
  855. Rect rc(0, 0, pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  856. pBmpImage->LockBits(
  857. rc,
  858. ImageLockModeRead,
  859. PixelFormat32bppARGB,
  860. &bitmapData);
  861. // Write to the temporary buffer provided by LockBits. RGB
  862. pixels = (UINT*)bitmapData.Scan0;
  863. DWORD wids=bitmapData.Stride/4;
  864. Color color;
  865. Color color1,color2,color3,color4,color5,color6,color7,color8;
  866. BYTE R,G,B;
  867. for(int aa=0; aa<RCARRARCOUNT; aa++)
  868. m_rcarray[aa].RemoveAll ();
  869. for( INT row = 0; row < rc.Height; ++row)
  870. {
  871. for(INT col = 0; col < rc.Width-1; ++col)
  872. {
  873. color.SetValue(pixels[row * wids + col]);
  874. if(color.GetA()<200)
  875. {
  876. CArray<int,int>*pArray=NULL;
  877. for(int aa=0; aa<RCARRARCOUNT; aa++)
  878. {
  879. if(m_rcarray[aa].GetSize () && pArray==NULL)
  880. {
  881. double x=m_rcarray[aa].ElementAt (0);
  882. double y=m_rcarray[aa].ElementAt (1);
  883. int x0=(int)x;
  884. int y0=(int)y;
  885. double dtx=col-x;
  886. double dty=row-y;
  887. if(abs(dtx)>abs(dty))
  888. {
  889. if(dty)
  890. {
  891. dtx/=abs(dty);
  892. dty/=abs(dty);
  893. }
  894. else if(dtx>0)
  895. dtx=1;
  896. else if(dtx<0)
  897. dtx=-1;
  898. }
  899. else
  900. {
  901. if(dtx)
  902. {
  903. dty/=abs(dtx);
  904. dtx/=abs(dtx);
  905. }
  906. else if(dty>0)
  907. dty=1;
  908. else if(dtx<0)
  909. dty=-1;
  910. }
  911. if(dtx>3)
  912. {
  913. double step=dtx/3.0;
  914. dtx/=step;
  915. dty/=step;
  916. }
  917. if(dty>3)
  918. {
  919. double step=dty/3.0;
  920. dtx/=step;
  921. dty/=step;
  922. }
  923. BOOL bFind=0;
  924. while(1)
  925. {
  926. x+=dtx;
  927. y+=dty;
  928. if(x>=(rc.Width-1) || x<1)break;
  929. if(y>=(rc.Height-1) || y<1)break;
  930. if(col>x0)
  931. {
  932. if(x<x0)
  933. {
  934. break;
  935. }
  936. if(x>col)
  937. {
  938. break;
  939. }
  940. }
  941. if(col<x0)
  942. {
  943. if(x>x0)
  944. {
  945. break;
  946. }
  947. if(x<col)
  948. {
  949. break;
  950. }
  951. }
  952. if(row>y0)
  953. {
  954. if(y<y0)
  955. {
  956. break;
  957. }
  958. if(y>row)
  959. {
  960. break;
  961. }
  962. }
  963. if(row<y0)
  964. {
  965. if(y>y0)
  966. {
  967. break;
  968. }
  969. if(y<row)
  970. {
  971. break;
  972. }
  973. }
  974. color.SetValue(pixels[(int)y * wids + (int)x]);
  975. if(color.GetA()==255)
  976. {
  977. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  978. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  979. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  980. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  981. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  982. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  983. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  984. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  985. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  986. {
  987. bFind=1;
  988. break;
  989. }
  990. }
  991. }
  992. if(bFind==0)pArray=&(m_rcarray[aa]);
  993. }
  994. }
  995. if(pArray==NULL)
  996. {
  997. BOOL bcontinue=1;
  998. for(int yy=0; yy<RCARRARCOUNT; yy++)
  999. {
  1000. if(m_rcarray[yy].GetSize ()==0)
  1001. {
  1002. pArray=&(m_rcarray[yy]);
  1003. bcontinue=0;
  1004. break;
  1005. }
  1006. }
  1007. if(bcontinue)continue;
  1008. }
  1009. pArray->Add (col);pArray->Add (row);
  1010. }
  1011. }
  1012. }
  1013. pBmpImage->UnlockBits(&bitmapData);
  1014. if(bdelete)delete pBmpImage;
  1015. /*
  1016. if(pBmpImage==NULL)return;
  1017. BitmapData bitmapData;
  1018. UINT* pixels;
  1019. Rect rc(0, 0, pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  1020. pBmpImage->LockBits(
  1021. rc,
  1022. ImageLockModeRead,
  1023. PixelFormat32bppARGB,
  1024. &bitmapData);
  1025. // Write to the temporary buffer provided by LockBits. RGB
  1026. pixels = (UINT*)bitmapData.Scan0;
  1027. DWORD wids=bitmapData.Stride/4;
  1028. Color color;
  1029. Color color1,color2,color3,color4,color5,color6,color7,color8;
  1030. BYTE R,G,B;
  1031. m_rcarray1.RemoveAll ();
  1032. m_rcarray2.RemoveAll ();
  1033. m_rcarray3.RemoveAll ();
  1034. m_rcarray4.RemoveAll ();
  1035. m_rcarray5.RemoveAll ();
  1036. for( INT row = 0; row < rc.Height; ++row)
  1037. {
  1038. for(INT col = 0; col < rc.Width-1; ++col)
  1039. {
  1040. color.SetValue(pixels[row * wids + col]);
  1041. if(color.GetA()<200)
  1042. {
  1043. CArray<int,int>*pArray=NULL;
  1044. if(m_rcarray1.GetSize () && pArray==NULL)
  1045. {
  1046. double x=m_rcarray1.ElementAt (0);
  1047. double y=m_rcarray1.ElementAt (1);
  1048. double dtx=col-x;
  1049. double dty=row-y;
  1050. dtx/=10.0;dty/=10.0;
  1051. BOOL bFind=0;
  1052. for(int a=0; a<10; a++)
  1053. {
  1054. x+=dtx;
  1055. y+=dty;
  1056. color.SetValue(pixels[(int)y * wids + (int)x]);
  1057. if(color.GetA()==255)
  1058. {
  1059. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1060. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1061. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1062. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1063. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1064. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1065. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1066. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1067. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  1068. {
  1069. bFind=1;
  1070. break;
  1071. }
  1072. }
  1073. }
  1074. if(bFind==0)pArray=&m_rcarray1;
  1075. }
  1076. if(m_rcarray2.GetSize () && pArray==NULL)
  1077. {
  1078. double x=m_rcarray2.ElementAt (0);
  1079. double y=m_rcarray2.ElementAt (1);
  1080. double dtx=col-x;dtx/=10.0;
  1081. double dty=row-y;dty/=10.0;
  1082. BOOL bFind=0;
  1083. for(int a=0; a<10; a++)
  1084. {
  1085. x+=dtx;
  1086. y+=dty;
  1087. color.SetValue(pixels[(int)y * wids + (int)x]);
  1088. if(color.GetA()==255)
  1089. {
  1090. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1091. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1092. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1093. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1094. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1095. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1096. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1097. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1098. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  1099. {
  1100. bFind=1;
  1101. break;
  1102. }
  1103. }
  1104. }
  1105. if(bFind==0)pArray=&m_rcarray2;
  1106. }
  1107. if(m_rcarray3.GetSize () && pArray==NULL)
  1108. {
  1109. double x=m_rcarray3.ElementAt (0);
  1110. double y=m_rcarray3.ElementAt (1);
  1111. double dtx=col-x;dtx/=10.0;
  1112. double dty=row-y;dty/=10.0;
  1113. BOOL bFind=0;
  1114. for(int a=0; a<10; a++)
  1115. {
  1116. x+=dtx;
  1117. y+=dty;
  1118. color.SetValue(pixels[(int)y * wids + (int)x]);
  1119. if(color.GetA()==255)
  1120. {
  1121. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1122. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1123. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1124. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1125. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1126. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1127. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1128. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1129. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  1130. {
  1131. bFind=1;
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. if(bFind==0)pArray=&m_rcarray3;
  1137. }
  1138. if(m_rcarray4.GetSize () && pArray==NULL)
  1139. {
  1140. double x=m_rcarray4.ElementAt (0);
  1141. double y=m_rcarray4.ElementAt (1);
  1142. double dtx=col-x;dtx/=10.0;
  1143. double dty=row-y;dty/=10.0;
  1144. BOOL bFind=0;
  1145. for(int a=0; a<10; a++)
  1146. {
  1147. x+=dtx;
  1148. y+=dty;
  1149. color.SetValue(pixels[(int)y * wids + (int)x]);
  1150. if(color.GetA()==255)
  1151. {
  1152. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1153. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1154. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1155. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1156. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1157. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1158. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1159. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1160. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  1161. {
  1162. bFind=1;
  1163. break;
  1164. }
  1165. }
  1166. }
  1167. if(bFind==0)pArray=&m_rcarray4;
  1168. }
  1169. if(m_rcarray5.GetSize () && pArray==NULL)
  1170. {
  1171. double x=m_rcarray5.ElementAt (0);
  1172. double y=m_rcarray5.ElementAt (1);
  1173. double dtx=col-x;dtx/=10.0;
  1174. double dty=row-y;dty/=10.0;
  1175. BOOL bFind=0;
  1176. for(int a=0; a<10; a++)
  1177. {
  1178. x+=dtx;
  1179. y+=dty;
  1180. color.SetValue(pixels[(int)y * wids + (int)x]);
  1181. if(color.GetA()==255)
  1182. {
  1183. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1184. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1185. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1186. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1187. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1188. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1189. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1190. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1191. if(color1.GetA()==255 && color2.GetA()==255 && color3.GetA()==255 && color4.GetA()==255 && color5.GetA()==255 && color6.GetA()==255 && color7.GetA()==255 && color8.GetA()==255)
  1192. {
  1193. bFind=1;
  1194. break;
  1195. }
  1196. }
  1197. }
  1198. if(bFind==0)pArray=&m_rcarray5;
  1199. }
  1200. if(pArray==NULL)
  1201. {
  1202. if(m_rcarray1.GetSize ()==0)
  1203. pArray=&m_rcarray1;
  1204. else if(m_rcarray2.GetSize ()==0)
  1205. pArray=&m_rcarray2;
  1206. else if(m_rcarray3.GetSize ()==0)
  1207. pArray=&m_rcarray3;
  1208. else if(m_rcarray4.GetSize ()==0)
  1209. pArray=&m_rcarray4;
  1210. else if(m_rcarray5.GetSize ()==0)
  1211. pArray=&m_rcarray5;
  1212. else continue;
  1213. }
  1214. pArray->Add (col);pArray->Add (row);
  1215. }
  1216. }
  1217. }
  1218. pBmpImage->UnlockBits(&bitmapData);
  1219. */
  1220. }