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. for(int i=0; i<array.GetSize (); i++)
  476. {
  477. Bitmap *img=NULL;
  478. ::LoadImageFromBuf (&img, array.ElementAt (i));
  479. if(img==NULL)continue;
  480. if(img->GetWidth()==0)continue;
  481. if(img->GetWidth()>2000 || img->GetHeight()>2000)
  482. {
  483. CRect rc(0,0,2000,2000);
  484. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  485. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  486. Graphics graphic(simg);graphic.Clear(Color(0,0,0,0));
  487. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  488. delete img;
  489. img=simg;
  490. }
  491. CString path;
  492. CString str=array.ElementAt (i);
  493. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  494. str=str.Left (str.Find ("."));
  495. /* InputName dlg;
  496. if(dlg.DoModal ()!=IDOK)
  497. {
  498. path.Format ("%s\\效果图-%d.png", g_path7, GetFileNo2());
  499. }
  500. else
  501. { */
  502. path.Format ("%s\\%s.png", g_path7, str);
  503. //}
  504. ::SaveImageToFile (img, path);
  505. str=path;
  506. CString spath=str.Left (str.ReverseFind ('\\')+1);
  507. spath+="s";
  508. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  509. spath.Replace ("png","jpg");
  510. CRect rc(0,0,100,100);
  511. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  512. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  513. Graphics graphic(simg);graphic.Clear(Color(0,0,0,0));
  514. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  515. ::SaveImageToFile (simg, spath);
  516. delete img;delete simg;
  517. }
  518. m_effectpos=0;
  519. m_photopos=0;
  520. m_effectpatharray.RemoveAll ();
  521. using namespace helper_coffs;
  522. ffsco o;
  523. o.dirs(0);
  524. o.find(LPCSTR(g_path7), LPCSTR("*.png"));
  525. ffsco::typeT coo;
  526. ffsco::typeT::iterator it;
  527. coo = o.co_file();
  528. for (it = coo.begin();
  529. coo.end() != it;
  530. it ++)
  531. {
  532. m_effectpatharray.Add ((*it).c_str());
  533. }
  534. if(m_effectpatharray.GetSize()==0)
  535. {
  536. AfxMessageBox("您还没有安装效果图!", MB_ICONINFORMATION);
  537. ::CreateDirectory (g_path7, NULL);
  538. }
  539. TerminateThread();
  540. CStringArray *pArray=&m_effectpatharray;
  541. m_vFileName.clear();
  542. for( i=0; i<pArray->GetSize (); i++)
  543. {
  544. CString filePath=pArray->ElementAt (i);
  545. filePath.MakeLower();
  546. m_vFileName.push_back(filePath);
  547. }
  548. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail16,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  549. m_bRunning=true;
  550. }
  551. void ShowEffectDlg::OnButton2()
  552. {
  553. POSITION pos;
  554. pos=m_List1.GetFirstSelectedItemPosition();
  555. if(pos==NULL)
  556. {
  557. return;
  558. }
  559. int selpos=m_List1.GetNextSelectedItem(pos);
  560. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  561. CString str=m_effectpatharray.ElementAt (selpos);
  562. CString spath=str.Left (str.ReverseFind ('\\')+1);
  563. spath+="s";
  564. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  565. spath.Replace ("png","jpg");
  566. ::DeleteFile (str);
  567. ::DeleteFile(spath);
  568. m_effectpatharray.RemoveAt (selpos);
  569. m_List1.DeleteItem (selpos); m_effectpos=0;
  570. m_photopos=0;
  571. }
  572. void ShowEffectDlg::OnLButtonDown(UINT nFlags, CPoint point)
  573. {
  574. // TODO: Add your message handler code here and/or call default
  575. // SetCapture();
  576. // m_startpt=point;
  577. CDialog::OnLButtonDown(nFlags, point);
  578. }
  579. void ShowEffectDlg::OnMouseMove(UINT nFlags, CPoint point)
  580. {
  581. // TODO: Add your message handler code here and/or call default
  582. /* if(GetCapture()!=this)return;
  583. if(m_rc.Width ()>m_rcscreen.Width ())
  584. {
  585. if(m_rc.left <m_rcscreen.left && point.x>m_startpt.x)
  586. {
  587. int dt=min(point.x-m_startpt.x, m_rcscreen.left-m_rc.left);
  588. m_rc.left +=dt;
  589. m_rc.right +=dt;
  590. }
  591. else if(m_rc.right >m_rcscreen.right && point.x<m_startpt.x)
  592. {
  593. int dt=min(m_startpt.x-point.x, m_rc.right-m_rcscreen.right);
  594. m_rc.left -=dt;
  595. m_rc.right -=dt;
  596. }
  597. }
  598. if(m_rc.Height ()>m_rcscreen.Height ())
  599. {
  600. if(m_rc.top <m_rcscreen.top && point.y>m_startpt.y)
  601. {
  602. int dt=min(point.y-m_startpt.y, m_rcscreen.top-m_rc.top);
  603. m_rc.top +=dt;
  604. m_rc.bottom +=dt;
  605. }
  606. else if(m_rc.bottom >m_rcscreen.bottom && point.y<m_startpt.y)
  607. {
  608. int dt=min(m_startpt.y-point.y, m_rc.bottom-m_rcscreen.bottom);
  609. m_rc.top -=dt;
  610. m_rc.bottom -=dt;
  611. }
  612. }
  613. m_startpt=point;
  614. RcChange();*/
  615. CDialog::OnMouseMove(nFlags, point);
  616. }
  617. void ShowEffectDlg::OnLButtonUp(UINT nFlags, CPoint point)
  618. {
  619. // TODO: Add your message handler code here and/or call default
  620. /* if(GetCapture()!=this)return;
  621. ReleaseCapture();*/
  622. CDialog::OnLButtonUp(nFlags, point);
  623. }
  624. BOOL ShowEffectDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  625. {
  626. // TODO: Add your message handler code here and/or call default
  627. /* if(m_pImage==NULL)return 1;
  628. if(zDelta>0)
  629. {
  630. m_fscale*=1.2;
  631. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  632. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  633. m_rc.left -=dtx;
  634. m_rc.right +=dtx;
  635. m_rc.top -=dty;
  636. m_rc.bottom +=dty;
  637. }
  638. else
  639. {
  640. if(m_fscale<=1)return 1;
  641. m_fscale/=1.2;
  642. if(m_fscale<1)m_fscale=1;
  643. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  644. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  645. m_rc.left -=dtx;
  646. m_rc.right +=dtx;
  647. m_rc.top -=dty;
  648. m_rc.bottom +=dty;
  649. if(m_rcbak.Height ()==m_rcscreen.Height ())
  650. {
  651. if(m_rc.top <m_rcscreen.top && m_rc.bottom < m_rcscreen.bottom )
  652. {
  653. dtx=m_rcscreen.bottom -m_rc.bottom;
  654. m_rc.top +=dtx;
  655. m_rc.bottom +=dtx;
  656. }
  657. else if(m_rc.top >m_rcscreen.top && m_rc.bottom > m_rcscreen.bottom )
  658. {
  659. dtx=m_rc.top-m_rcscreen.top;
  660. m_rc.top -=dtx;
  661. m_rc.bottom -=dtx;
  662. }
  663. dtx=m_rc.Width ();
  664. m_rc.left =(m_rcscreen.Width ()-dtx)/2;
  665. m_rc.right =m_rc.left +dtx;
  666. }
  667. if(m_rcbak.Width ()==m_rcscreen.Width ())
  668. {
  669. if(m_rc.left <m_rcscreen.left && m_rc.right < m_rcscreen.right )
  670. {
  671. dtx=m_rcscreen.right -m_rc.right;
  672. m_rc.left +=dtx;
  673. m_rc.right +=dtx;
  674. }
  675. else if(m_rc.left >m_rcscreen.left && m_rc.right > m_rcscreen.right )
  676. {
  677. dtx=m_rc.left-m_rcscreen.left;
  678. m_rc.left -=dtx;
  679. m_rc.right -=dtx;
  680. }
  681. dtx=m_rc.Height ();
  682. m_rc.top =(m_rcscreen.Height ()-dtx)/2;
  683. m_rc.bottom =m_rc.top +dtx;
  684. }
  685. }
  686. RcChange();*/
  687. return CDialog::OnMouseWheel(nFlags, zDelta, pt);
  688. }
  689. void ShowEffectDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  690. {
  691. // TODO: Add your control notification handler code here
  692. POSITION pos;
  693. pos=m_List1.GetFirstSelectedItemPosition();
  694. if(pos==NULL)
  695. {
  696. return;
  697. }
  698. m_effectpos=m_List1.GetNextSelectedItem(pos);m_bLoadEffect=1;
  699. MakeEffect();
  700. *pResult = 0;
  701. }
  702. void ShowEffectDlg::OnTimer(UINT nIDEvent)
  703. {
  704. // TODO: Add your message handler code here and/or call default
  705. KillTimer(nIDEvent);
  706. MakeEffect();
  707. }
  708. void ShowEffectDlg::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  709. {
  710. // TODO: Add your control notification handler code here
  711. POSITION pos;
  712. pos=m_List2.GetFirstSelectedItemPosition();
  713. if(pos==NULL)
  714. {
  715. return;
  716. }
  717. m_photopos=m_List2.GetNextSelectedItem(pos); m_bLoadPhoto=1;
  718. MakeEffect();
  719. *pResult = 0;
  720. }
  721. int GetLengFromPt(CPoint pt1, CPoint pt2)
  722. {
  723. return (pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y);
  724. }
  725. int GetLengFromPt2(CPoint pt1, CPoint pt2)
  726. {
  727. return sqrt((pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
  728. }
  729. void ShowEffectDlg::MakeEffect()
  730. {
  731. if(m_effectpatharray.GetSize()==0)return;
  732. Graphics graph(m_pbmp);
  733. graph.Clear(Color(255,255,255,255));
  734. if(m_bLoadPhoto)
  735. {
  736. if(m_pPhoto)delete m_pPhoto;m_pPhoto=NULL;
  737. }
  738. if(m_bLoadEffect)
  739. {
  740. if(m_pImage)delete m_pImage;m_pImage=NULL;
  741. if(m_pImagebak)delete m_pImagebak;m_pImagebak=NULL;
  742. ::LoadImageFromBuf (&m_pImage, m_effectpatharray.ElementAt (m_effectpos));
  743. if(m_pPhotopatharray->GetSize ())GetRgn(m_pImage);
  744. m_pImagebak=m_pImage->Clone(0,0,m_pImage->GetWidth(),m_pImage->GetHeight(),PixelFormat32bppARGB );
  745. }
  746. int width,height;
  747. width=m_pImage->GetWidth();
  748. height=m_pImage->GetHeight();
  749. if(width==0 || height==0)return;
  750. InitRc(m_pImage);
  751. CPoint pt1,pt2,pt3;
  752. int leng1,leng2,leng3;
  753. CPoint curpt;
  754. int leng;
  755. Graphics graph2(m_pImage);
  756. if(m_pPhotopatharray->GetSize ())
  757. {
  758. if(m_bLoadPhoto)
  759. ::LoadImageFromBuf (&m_pPhoto, m_pPhotopatharray->ElementAt (m_photopos));
  760. int i;
  761. for(int aa=0; aa<RCARRARCOUNT; aa++)
  762. {
  763. leng1=leng2=leng3=10000000;
  764. for( i=0; i<m_rcarray[aa].GetSize (); i+=2)
  765. {
  766. curpt.x=m_rcarray[aa].ElementAt (i);
  767. curpt.y=m_rcarray[aa].ElementAt (i+1);
  768. leng=GetLengFromPt(CPoint(0,0), curpt);
  769. if(leng<leng1)
  770. {
  771. leng1=leng;
  772. pt1=curpt;
  773. }
  774. leng=GetLengFromPt(CPoint(m_pImage->GetWidth(),0), curpt);
  775. if(leng<leng2)
  776. {
  777. leng2=leng;
  778. pt2=curpt;
  779. }
  780. leng=GetLengFromPt(CPoint(0,m_pImage->GetHeight()), curpt);
  781. if(leng<leng3)
  782. {
  783. leng3=leng;
  784. pt3=curpt;
  785. }
  786. }
  787. if(m_rcarray[aa].GetSize ())
  788. {
  789. pt1.x*=m_tempscale;
  790. pt1.y*=m_tempscale;
  791. pt2.x*=m_tempscale;
  792. pt2.y*=m_tempscale;
  793. pt3.x*=m_tempscale;
  794. pt3.y*=m_tempscale;
  795. Point destinationPoints[] = {
  796. Point(pt1.x, pt1.y), // destination for upper-left point of original
  797. Point(pt2.x, pt2.y), // destination for upper-right point of original
  798. Point(pt3.x, pt3.y)}; // destination for lower-left point of original
  799. // graph2.DrawImage(m_pPhoto, destinationPoints, 3);
  800. int lengx=GetLengFromPt2(pt1, pt2);
  801. int lengy=GetLengFromPt2(pt1, pt3);
  802. /* CString ss;
  803. ss.Format("pt1:%d,%d pt2:%d,%d leng:%d", pt1.x, pt1.y,pt2.x, pt2.y,lengx);
  804. AfxMessageBox(ss);
  805. ss.Format("pt1:%d,%d pt3:%d,%d leng:%d", pt1.x, pt1.y,pt3.x, pt3.y,lengy);
  806. AfxMessageBox(ss);*/
  807. CRect rc(0,0,m_pPhoto->GetWidth(),m_pPhoto->GetHeight());
  808. RectFitDes(lengx,lengy,rc);
  809. graph2.DrawImage(
  810. m_pPhoto,
  811. destinationPoints,
  812. 3,
  813. rc.left,
  814. rc.top,
  815. rc.Width(),
  816. rc.Height(),
  817. UnitPixel,
  818. NULL,
  819. NULL,
  820. NULL);
  821. }
  822. }
  823. ///////
  824. graph2.DrawImage(m_pImagebak, 0, 0);
  825. }
  826. Rect destinationRect( m_rc.left , m_rc.top , m_rc.Width (), m_rc.Height () );
  827. graph.DrawImage(m_pImage, destinationRect, 0,0,width,height,UnitPixel);
  828. CRect rc;
  829. GetClientRect(rc);
  830. rc.left +=110;
  831. rc.right -=110;
  832. InvalidateRect(rc);
  833. m_bLoadEffect=0;
  834. m_bLoadPhoto=0;
  835. }
  836. void ShowEffectDlg::GetRgn(Bitmap *pBmpImage2)
  837. {
  838. m_tempscale=1.0;
  839. if(pBmpImage2==NULL)return;
  840. Bitmap *pBmpImage=NULL;
  841. BOOL bdelete=0;
  842. if(pBmpImage2->GetWidth()>800 || pBmpImage2->GetHeight()>800)
  843. {
  844. bdelete=1;
  845. CRect rc(0,0,800,800);
  846. RectFitDes(pBmpImage2->GetWidth(), pBmpImage2->GetHeight(), rc);
  847. pBmpImage=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  848. Graphics graphic(pBmpImage);graphic.Clear(Color(0,0,0,0));
  849. graphic.DrawImage(pBmpImage2, 0,0,pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  850. m_tempscale=(float)pBmpImage2->GetWidth()/(float)pBmpImage->GetWidth();
  851. }
  852. else
  853. pBmpImage=pBmpImage2;
  854. BitmapData bitmapData;
  855. UINT* pixels;
  856. Rect rc(0, 0, pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  857. pBmpImage->LockBits(
  858. rc,
  859. ImageLockModeRead,
  860. PixelFormat32bppARGB,
  861. &bitmapData);
  862. // Write to the temporary buffer provided by LockBits. RGB
  863. pixels = (UINT*)bitmapData.Scan0;
  864. DWORD wids=bitmapData.Stride/4;
  865. Color color;
  866. Color color1,color2,color3,color4,color5,color6,color7,color8;
  867. BYTE R,G,B;
  868. for(int aa=0; aa<RCARRARCOUNT; aa++)
  869. m_rcarray[aa].RemoveAll ();
  870. for( INT row = 0; row < rc.Height; ++row)
  871. {
  872. for(INT col = 0; col < rc.Width-1; ++col)
  873. {
  874. color.SetValue(pixels[row * wids + col]);
  875. if(color.GetA()<200)
  876. {
  877. CArray<int,int>*pArray=NULL;
  878. for(int aa=0; aa<RCARRARCOUNT; aa++)
  879. {
  880. if(m_rcarray[aa].GetSize () && pArray==NULL)
  881. {
  882. double x=m_rcarray[aa].ElementAt (0);
  883. double y=m_rcarray[aa].ElementAt (1);
  884. int x0=(int)x;
  885. int y0=(int)y;
  886. double dtx=col-x;
  887. double dty=row-y;
  888. if(abs(dtx)>abs(dty))
  889. {
  890. if(dty)
  891. {
  892. dtx/=abs(dty);
  893. dty/=abs(dty);
  894. }
  895. else if(dtx>0)
  896. dtx=1;
  897. else if(dtx<0)
  898. dtx=-1;
  899. }
  900. else
  901. {
  902. if(dtx)
  903. {
  904. dty/=abs(dtx);
  905. dtx/=abs(dtx);
  906. }
  907. else if(dty>0)
  908. dty=1;
  909. else if(dtx<0)
  910. dty=-1;
  911. }
  912. if(dtx>3)
  913. {
  914. double step=dtx/3.0;
  915. dtx/=step;
  916. dty/=step;
  917. }
  918. if(dty>3)
  919. {
  920. double step=dty/3.0;
  921. dtx/=step;
  922. dty/=step;
  923. }
  924. BOOL bFind=0;
  925. while(1)
  926. {
  927. x+=dtx;
  928. y+=dty;
  929. if(x>=(rc.Width-1) || x<1)break;
  930. if(y>=(rc.Height-1) || y<1)break;
  931. if(col>x0)
  932. {
  933. if(x<x0)
  934. {
  935. break;
  936. }
  937. if(x>col)
  938. {
  939. break;
  940. }
  941. }
  942. if(col<x0)
  943. {
  944. if(x>x0)
  945. {
  946. break;
  947. }
  948. if(x<col)
  949. {
  950. break;
  951. }
  952. }
  953. if(row>y0)
  954. {
  955. if(y<y0)
  956. {
  957. break;
  958. }
  959. if(y>row)
  960. {
  961. break;
  962. }
  963. }
  964. if(row<y0)
  965. {
  966. if(y>y0)
  967. {
  968. break;
  969. }
  970. if(y<row)
  971. {
  972. break;
  973. }
  974. }
  975. color.SetValue(pixels[(int)y * wids + (int)x]);
  976. if(color.GetA()==255)
  977. {
  978. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  979. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  980. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  981. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  982. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  983. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  984. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  985. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  986. 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)
  987. {
  988. bFind=1;
  989. break;
  990. }
  991. }
  992. }
  993. if(bFind==0)pArray=&(m_rcarray[aa]);
  994. }
  995. }
  996. if(pArray==NULL)
  997. {
  998. BOOL bcontinue=1;
  999. for(int yy=0; yy<RCARRARCOUNT; yy++)
  1000. {
  1001. if(m_rcarray[yy].GetSize ()==0)
  1002. {
  1003. pArray=&(m_rcarray[yy]);
  1004. bcontinue=0;
  1005. break;
  1006. }
  1007. }
  1008. if(bcontinue)continue;
  1009. }
  1010. pArray->Add (col);pArray->Add (row);
  1011. }
  1012. }
  1013. }
  1014. pBmpImage->UnlockBits(&bitmapData);
  1015. if(bdelete)delete pBmpImage;
  1016. /*
  1017. if(pBmpImage==NULL)return;
  1018. BitmapData bitmapData;
  1019. UINT* pixels;
  1020. Rect rc(0, 0, pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  1021. pBmpImage->LockBits(
  1022. rc,
  1023. ImageLockModeRead,
  1024. PixelFormat32bppARGB,
  1025. &bitmapData);
  1026. // Write to the temporary buffer provided by LockBits. RGB
  1027. pixels = (UINT*)bitmapData.Scan0;
  1028. DWORD wids=bitmapData.Stride/4;
  1029. Color color;
  1030. Color color1,color2,color3,color4,color5,color6,color7,color8;
  1031. BYTE R,G,B;
  1032. m_rcarray1.RemoveAll ();
  1033. m_rcarray2.RemoveAll ();
  1034. m_rcarray3.RemoveAll ();
  1035. m_rcarray4.RemoveAll ();
  1036. m_rcarray5.RemoveAll ();
  1037. for( INT row = 0; row < rc.Height; ++row)
  1038. {
  1039. for(INT col = 0; col < rc.Width-1; ++col)
  1040. {
  1041. color.SetValue(pixels[row * wids + col]);
  1042. if(color.GetA()<200)
  1043. {
  1044. CArray<int,int>*pArray=NULL;
  1045. if(m_rcarray1.GetSize () && pArray==NULL)
  1046. {
  1047. double x=m_rcarray1.ElementAt (0);
  1048. double y=m_rcarray1.ElementAt (1);
  1049. double dtx=col-x;
  1050. double dty=row-y;
  1051. dtx/=10.0;dty/=10.0;
  1052. BOOL bFind=0;
  1053. for(int a=0; a<10; a++)
  1054. {
  1055. x+=dtx;
  1056. y+=dty;
  1057. color.SetValue(pixels[(int)y * wids + (int)x]);
  1058. if(color.GetA()==255)
  1059. {
  1060. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1061. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1062. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1063. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1064. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1065. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1066. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1067. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1068. 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)
  1069. {
  1070. bFind=1;
  1071. break;
  1072. }
  1073. }
  1074. }
  1075. if(bFind==0)pArray=&m_rcarray1;
  1076. }
  1077. if(m_rcarray2.GetSize () && pArray==NULL)
  1078. {
  1079. double x=m_rcarray2.ElementAt (0);
  1080. double y=m_rcarray2.ElementAt (1);
  1081. double dtx=col-x;dtx/=10.0;
  1082. double dty=row-y;dty/=10.0;
  1083. BOOL bFind=0;
  1084. for(int a=0; a<10; a++)
  1085. {
  1086. x+=dtx;
  1087. y+=dty;
  1088. color.SetValue(pixels[(int)y * wids + (int)x]);
  1089. if(color.GetA()==255)
  1090. {
  1091. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1092. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1093. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1094. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1095. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1096. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1097. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1098. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1099. 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)
  1100. {
  1101. bFind=1;
  1102. break;
  1103. }
  1104. }
  1105. }
  1106. if(bFind==0)pArray=&m_rcarray2;
  1107. }
  1108. if(m_rcarray3.GetSize () && pArray==NULL)
  1109. {
  1110. double x=m_rcarray3.ElementAt (0);
  1111. double y=m_rcarray3.ElementAt (1);
  1112. double dtx=col-x;dtx/=10.0;
  1113. double dty=row-y;dty/=10.0;
  1114. BOOL bFind=0;
  1115. for(int a=0; a<10; a++)
  1116. {
  1117. x+=dtx;
  1118. y+=dty;
  1119. color.SetValue(pixels[(int)y * wids + (int)x]);
  1120. if(color.GetA()==255)
  1121. {
  1122. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1123. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1124. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1125. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1126. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1127. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1128. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1129. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1130. 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)
  1131. {
  1132. bFind=1;
  1133. break;
  1134. }
  1135. }
  1136. }
  1137. if(bFind==0)pArray=&m_rcarray3;
  1138. }
  1139. if(m_rcarray4.GetSize () && pArray==NULL)
  1140. {
  1141. double x=m_rcarray4.ElementAt (0);
  1142. double y=m_rcarray4.ElementAt (1);
  1143. double dtx=col-x;dtx/=10.0;
  1144. double dty=row-y;dty/=10.0;
  1145. BOOL bFind=0;
  1146. for(int a=0; a<10; a++)
  1147. {
  1148. x+=dtx;
  1149. y+=dty;
  1150. color.SetValue(pixels[(int)y * wids + (int)x]);
  1151. if(color.GetA()==255)
  1152. {
  1153. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1154. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1155. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1156. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1157. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1158. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1159. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1160. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1161. 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)
  1162. {
  1163. bFind=1;
  1164. break;
  1165. }
  1166. }
  1167. }
  1168. if(bFind==0)pArray=&m_rcarray4;
  1169. }
  1170. if(m_rcarray5.GetSize () && pArray==NULL)
  1171. {
  1172. double x=m_rcarray5.ElementAt (0);
  1173. double y=m_rcarray5.ElementAt (1);
  1174. double dtx=col-x;dtx/=10.0;
  1175. double dty=row-y;dty/=10.0;
  1176. BOOL bFind=0;
  1177. for(int a=0; a<10; a++)
  1178. {
  1179. x+=dtx;
  1180. y+=dty;
  1181. color.SetValue(pixels[(int)y * wids + (int)x]);
  1182. if(color.GetA()==255)
  1183. {
  1184. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1185. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1186. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1187. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1188. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1189. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1190. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1191. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1192. 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)
  1193. {
  1194. bFind=1;
  1195. break;
  1196. }
  1197. }
  1198. }
  1199. if(bFind==0)pArray=&m_rcarray5;
  1200. }
  1201. if(pArray==NULL)
  1202. {
  1203. if(m_rcarray1.GetSize ()==0)
  1204. pArray=&m_rcarray1;
  1205. else if(m_rcarray2.GetSize ()==0)
  1206. pArray=&m_rcarray2;
  1207. else if(m_rcarray3.GetSize ()==0)
  1208. pArray=&m_rcarray3;
  1209. else if(m_rcarray4.GetSize ()==0)
  1210. pArray=&m_rcarray4;
  1211. else if(m_rcarray5.GetSize ()==0)
  1212. pArray=&m_rcarray5;
  1213. else continue;
  1214. }
  1215. pArray->Add (col);pArray->Add (row);
  1216. }
  1217. }
  1218. }
  1219. pBmpImage->UnlockBits(&bitmapData);
  1220. */
  1221. }