ShowEffect.cpp 34 KB

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