ShowEffect.cpp 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  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_pImgFinalShow=NULL;
  18. m_pImgPNG=NULL;
  19. m_pImgPNGbake=NULL;
  20. m_pImgJPG=NULL;
  21. //}}AFX_DATA_INIT
  22. m_nPNGIndex=0;
  23. m_nJPGIndex=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_bLoadPNG=1;
  32. m_bLoadJPG=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_ListJPG);
  39. DDX_Control(pDX, IDC_LIST1, m_ListPNG);
  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_ListJPG;
  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_vJPGFile.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_vJPGFile.begin(); iter!=pDlg->m_vJPGFile.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_vJPGFile.begin(); iter!=pDlg->m_vJPGFile.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 (PathFileExists(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. return true;
  158. }
  159. unsigned __stdcall LoadThumbNail16(LPVOID lpParam)
  160. {
  161. try
  162. {
  163. ShowEffectDlg *pDlg=(ShowEffectDlg*)lpParam;
  164. CListCtrl *ListCtrl=&pDlg->m_ListPNG;
  165. CImageList* pImgList=&pDlg->m_ImageListThumb;
  166. // reset our image list
  167. for(int i=0; i<pImgList->GetImageCount(); i++)
  168. pImgList->Remove(i);
  169. // remove all items from list view
  170. ListCtrl->DeleteAllItems();
  171. pImgList->SetImageCount(pDlg->m_vPNGFile.size());
  172. TCHAR path[MAX_PATH];
  173. vector<CString>::iterator iter;
  174. // Set redraw to FALSE to avoid flickering during adding new items
  175. ListCtrl->SetRedraw(FALSE);
  176. int nIndex=0;
  177. CString str, spath;
  178. for(iter=pDlg->m_vPNGFile.begin(); iter!=pDlg->m_vPNGFile.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  179. {
  180. str=*iter;
  181. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  182. str=str.Left (str.Find ("."));
  183. ListCtrl->InsertItem(nIndex, str, nIndex);
  184. }
  185. ListCtrl->SetRedraw(TRUE);
  186. ListCtrl->Invalidate();
  187. const float fRatio=(float)THUMBNAIL_HEIGHT/THUMBNAIL_WIDTH;
  188. int XDest, YDest, nDestWidth, nDestHeight;
  189. nIndex=0;
  190. SolidBrush whitebrush(Color(255,255,255,255));
  191. for(iter=pDlg->m_vPNGFile.begin(); iter!=pDlg->m_vPNGFile.end() && pDlg->m_bTerminate!=true; iter++, nIndex++)
  192. {
  193. // Load Image File
  194. Image *image=NULL;
  195. Bitmap *pBmp=NULL;
  196. str=*iter;
  197. spath=str.Left (str.ReverseFind ('\\')+1);
  198. spath+="s";
  199. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  200. spath.Replace ("png","jpg");
  201. if (PathFileExists(spath))
  202. {
  203. ::LoadImageFromBuf (&image, spath);
  204. }
  205. else
  206. ::LoadImageFromBuf (&image, str);
  207. int orientation=GetOrientation(image);
  208. if(orientation==8)
  209. image->RotateFlip( Rotate270FlipNone );
  210. else if(orientation==6)
  211. image->RotateFlip( Rotate90FlipNone );
  212. if(image->GetWidth()==0)
  213. continue;
  214. // Calculate Rect to fit to canvas
  215. const float fImgRatio=(float)image->GetHeight()/image->GetWidth();
  216. if(fImgRatio > fRatio)
  217. {
  218. nDestWidth=THUMBNAIL_HEIGHT/fImgRatio;
  219. XDest=(THUMBNAIL_WIDTH-nDestWidth)/2;
  220. YDest=0;
  221. nDestHeight=THUMBNAIL_HEIGHT;
  222. }
  223. else
  224. {
  225. XDest=0;
  226. nDestWidth=THUMBNAIL_WIDTH;
  227. nDestHeight=THUMBNAIL_WIDTH*fImgRatio;
  228. YDest=(THUMBNAIL_HEIGHT-nDestHeight)/2;
  229. }
  230. pBmp=new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB );
  231. Graphics graph2(pBmp);
  232. graph2.Clear(Color(255,192,192,192));
  233. graph2.FillRectangle (&whitebrush,1, 1, THUMBNAIL_WIDTH-2, THUMBNAIL_HEIGHT-2);
  234. Graphics graph(pBmp);
  235. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  236. // Draw Image
  237. graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
  238. delete image;
  239. // Attach to Bitmap and Replace image in CImageList
  240. CBitmap bitmap;
  241. HBITMAP hbmp;
  242. pBmp->GetHBITMAP(Color(255,255,255,255), &hbmp);
  243. bitmap.Attach(hbmp);
  244. pImgList->Replace(nIndex, &bitmap, NULL);
  245. delete pBmp;
  246. // Redraw only a current item for removing flickering and fast speed.
  247. ListCtrl->RedrawItems(nIndex, nIndex);
  248. // Release used DC and Object
  249. }
  250. ListCtrl->Invalidate();
  251. pDlg->m_bRunning=false;
  252. pDlg->m_bTerminate=false;
  253. _endthreadex( 0 );
  254. return 0;
  255. }
  256. catch(...)
  257. {
  258. }
  259. return true;
  260. }
  261. BOOL ShowEffectDlg::OnInitDialog()
  262. {
  263. CDialog::OnInitDialog();
  264. GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(49));
  265. // 获取所有PNG效果图;
  266. using namespace helper_coffs;
  267. ffsco o;
  268. o.dirs(0);
  269. o.find(LPCSTR(g_path7), LPCSTR(_T("*.png")));
  270. ffsco::typeT coo;
  271. ffsco::typeT::iterator it;
  272. coo = o.co_file();
  273. for (it = coo.begin(); coo.end() != it; it ++)
  274. {
  275. m_AryPNGImgpaths.Add((*it).c_str());
  276. }
  277. if(m_AryPNGImgpaths.GetSize()==0)
  278. {
  279. AfxMessageBox(_T("您还没有安装效果图!"), MB_ICONINFORMATION);
  280. ::CreateDirectory (g_path7, NULL);
  281. }
  282. // Jeff.m_rcscreen:屏幕尺寸;
  283. ::SetWindowPos(m_hWnd,HWND_TOP,0 ,0,g_screenwid,g_screenhei,SWP_SHOWWINDOW);
  284. m_rcscreen=CRect(0, 0, g_screenwid, g_screenhei);
  285. // Jeff.rc:临时区域;
  286. // Jeff.rc2:客户区域大小,用于放置PNG效果图;
  287. // Jeff.rc3:按钮区域;
  288. CRect rc,rc2,rc3;
  289. GetClientRect(rc2);
  290. GetDlgItem(IDC_BUTTON1)->GetWindowRect(rc3);
  291. ScreenToClient(rc3);
  292. rc=rc2;
  293. rc.right =110;
  294. rc.top =rc3.bottom +rc3.top;
  295. m_ListPNG.MoveWindow(rc);
  296. rc=rc2;
  297. rc.left=rc.right-110;
  298. m_ListJPG.MoveWindow(rc);
  299. // m_pbmp:最终显示PNG效果图的Bimap对象(PNG+客人相片 合二为一的结果);
  300. rc=rc2;
  301. rc.left +=110;
  302. rc.right -=110;
  303. m_pImgFinalShow = new Bitmap(rc.Width (), rc.Height (), PixelFormat24bppRGB );
  304. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  305. m_ListPNG.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  306. m_ImageListThumb2.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  307. m_ListJPG.SetImageList(&m_ImageListThumb2, LVSIL_NORMAL);
  308. // 加载PGN效果图到List列表中;
  309. if(m_bRunning)return 0;
  310. CStringArray *pArray = &m_AryPNGImgpaths;
  311. m_vPNGFile.clear();
  312. for(int i=0; i<pArray->GetSize (); i++)
  313. {
  314. CString filePath=pArray->ElementAt (i);
  315. filePath.MakeLower();
  316. m_vPNGFile.push_back(filePath);
  317. }
  318. TerminateThread();
  319. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail16,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  320. m_bRunning=true;
  321. // 加载选片界面的相片到List列表中;
  322. {
  323. if(m_bRunning2)return 0;
  324. CStringArray *pArray=m_pPhotopatharray;
  325. m_vJPGFile.clear();
  326. for(int i=0; i<pArray->GetSize (); i++)
  327. {
  328. CString filePath=pArray->ElementAt (i);
  329. filePath.MakeLower();
  330. m_vJPGFile.push_back(filePath);
  331. }
  332. TerminateThread2();
  333. m_hThread2 = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail17,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID2);
  334. m_bRunning2=true;
  335. }
  336. SetTimer(1, 200, NULL);
  337. return TRUE; // return TRUE unless you set the focus to a control
  338. // EXCEPTION: OCX Property Pages should return FALSE
  339. }
  340. BOOL ShowEffectDlg::TerminateThread()
  341. {
  342. if ( !m_bRunning )
  343. return TRUE;
  344. m_bTerminate=true;
  345. for( ; ; )
  346. {
  347. if ( ::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0 )
  348. break;
  349. MSG msg;
  350. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  351. {
  352. if (!AfxGetApp()->PumpMessage())
  353. break;
  354. }
  355. }
  356. ::CloseHandle(m_hThread);
  357. return TRUE;
  358. }
  359. BOOL ShowEffectDlg::TerminateThread2()
  360. {
  361. if ( !m_bRunning2 )
  362. return TRUE;
  363. m_bTerminate2=true;
  364. for( ; ; )
  365. {
  366. if ( ::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0 )
  367. break;
  368. MSG msg;
  369. while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
  370. {
  371. if (!AfxGetApp()->PumpMessage())
  372. break;
  373. }
  374. }
  375. ::CloseHandle(m_hThread2);
  376. return TRUE;
  377. }
  378. void ShowEffectDlg::OnDestroy()
  379. {
  380. // TODO: Add your message handler code here
  381. TerminateThread2();
  382. TerminateThread();
  383. if(m_pImgFinalShow)
  384. delete m_pImgFinalShow;
  385. m_pImgFinalShow=NULL;
  386. if(m_pImgPNG)
  387. delete m_pImgPNG;
  388. m_pImgPNG=NULL;
  389. if(m_pImgPNGbake)
  390. delete m_pImgPNGbake;
  391. m_pImgPNGbake=NULL;
  392. if(m_pImgJPG)
  393. delete m_pImgJPG;
  394. m_pImgJPG=NULL;
  395. CDialog::OnDestroy();
  396. }
  397. void ShowEffectDlg::OnPaint()
  398. {
  399. CPaintDC dc(this); // device context for painting
  400. // TODO: Add your message handler code here
  401. try
  402. {
  403. if(m_pImgFinalShow)
  404. {
  405. Graphics graph2(dc.GetSafeHdc ());
  406. graph2.DrawImage(m_pImgFinalShow,110,0);
  407. }
  408. }
  409. catch(...)
  410. {
  411. }
  412. // Do not call CDialog::OnPaint() for painting messages
  413. }
  414. BOOL ShowEffectDlg::OnEraseBkgnd(CDC* pDC)
  415. {
  416. // TODO: Add your message handler code here and/or call default
  417. return 1;
  418. }
  419. void ShowEffectDlg::InitRc(Image *img)
  420. {
  421. try
  422. {
  423. if(img==NULL)return;
  424. CRect rc;
  425. GetClientRect(rc);
  426. rc.right -=220;
  427. m_rc=rc;
  428. int width,height;
  429. width=img->GetWidth();
  430. height=img->GetHeight();
  431. //////////
  432. float fscale=(float)width/(float)height;
  433. float rcscale=((float)m_rc.Width ())/((float)m_rc.Height ());
  434. int rcwid=m_rc.Width ();
  435. int rchei=m_rc.Height ();
  436. int dt=0;
  437. if(rcscale<fscale)
  438. {
  439. dt=(rchei-rcwid/fscale)/2;
  440. m_rc.top+=dt;
  441. m_rc.bottom-=dt;
  442. }
  443. else
  444. {
  445. dt=(rcwid-rchei*fscale)/2;
  446. m_rc.left +=dt;
  447. m_rc.right-=dt;
  448. }
  449. m_rcbak=m_rc;
  450. }
  451. catch(...)
  452. {
  453. }
  454. }
  455. void ShowEffectDlg::RcChange()
  456. {
  457. }
  458. int GetFileNo2()
  459. {
  460. CString path;
  461. int begin=1;
  462. path.Format ("%s\\效果图-%d.png", g_path7, begin);
  463. while (PathFileExists(path))
  464. {
  465. begin++;
  466. path.Format ("%s\\效果图-%d.png", g_path7, begin);
  467. }
  468. return begin;
  469. }
  470. extern void SaveImageToFile(Image *img, CString path);
  471. void ShowEffectDlg::OnButton1()
  472. {
  473. if(AfxMessageBox("制作方法:\r\n1.图片格式为透明PNG格式.\r\n2.显示客照的位置为透明.", MB_ICONINFORMATION));
  474. CFileDialog fdlg(true, NULL,"openfile", OFN_ALLOWMULTISELECT,"png文件(*.png)|*.png||");
  475. TCHAR szBuffer[60000]={0};
  476. fdlg.m_ofn.lpstrFile = szBuffer;
  477. fdlg.m_ofn.nMaxFile = 60000;
  478. if(fdlg.DoModal ()!=IDOK)
  479. {
  480. return;
  481. }
  482. POSITION pos=fdlg.GetStartPosition ();
  483. CStringArray array;
  484. while(pos!=NULL)
  485. {
  486. array.Add(fdlg.GetNextPathName (pos));
  487. }
  488. if(array.GetSize ()==0)return;
  489. int i = 0;
  490. for( i=0; i<array.GetSize (); i++)
  491. {
  492. Bitmap *img=NULL;
  493. //::LoadImageFromBuf(&img, array.ElementAt(i));
  494. LoadImageFromBuf((Image**)&img, array.ElementAt(i));
  495. if(img==NULL)continue;
  496. if(img->GetWidth()==0)continue;
  497. if(img->GetWidth()>2000 || img->GetHeight()>2000)
  498. {
  499. CRect rc(0,0,2000,2000);
  500. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  501. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  502. Graphics graphic(simg);
  503. graphic.Clear(Color(0,0,0,0));
  504. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  505. delete img;
  506. img=simg;
  507. }
  508. CString path;
  509. CString str=array.ElementAt (i);
  510. str=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  511. str=str.Left (str.Find ("."));
  512. /* InputName dlg;
  513. if(dlg.DoModal ()!=IDOK)
  514. {
  515. path.Format ("%s\\效果图-%d.png", g_path7, GetFileNo2());
  516. }
  517. else
  518. { */
  519. path.Format ("%s\\%s.png", g_path7, str);
  520. //}
  521. ::SaveImageToFile (img, path);
  522. str=path;
  523. CString spath=str.Left (str.ReverseFind ('\\')+1);
  524. spath+="s";
  525. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  526. spath.Replace ("png","jpg");
  527. CRect rc(0,0,100,100);
  528. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  529. Bitmap *simg=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  530. Graphics graphic(simg);graphic.Clear(Color(0,0,0,0));
  531. graphic.DrawImage(img, 0,0,simg->GetWidth(), simg->GetHeight() );
  532. ::SaveImageToFile (simg, spath);
  533. delete img;delete simg;
  534. }
  535. m_nPNGIndex=0;
  536. m_nJPGIndex=0;
  537. m_AryPNGImgpaths.RemoveAll ();
  538. using namespace helper_coffs;
  539. ffsco o;
  540. o.dirs(0);
  541. o.find(LPCSTR(g_path7), LPCSTR(_T("*.png")));
  542. ffsco::typeT coo;
  543. ffsco::typeT::iterator it;
  544. coo = o.co_file();
  545. for (it = coo.begin(); coo.end() != it; it ++)
  546. {
  547. m_AryPNGImgpaths.Add((*it).c_str());
  548. }
  549. if(m_AryPNGImgpaths.GetSize()==0)
  550. {
  551. AfxMessageBox(_T("您还没有安装效果图!"), MB_ICONINFORMATION);
  552. ::CreateDirectory (g_path7, NULL);
  553. }
  554. TerminateThread();
  555. CStringArray *pArray=&m_AryPNGImgpaths;
  556. m_vPNGFile.clear();
  557. for( i=0; i<pArray->GetSize (); i++)
  558. {
  559. CString filePath=pArray->ElementAt (i);
  560. filePath.MakeLower();
  561. m_vPNGFile.push_back(filePath);
  562. }
  563. m_hThread = (HANDLE)_beginthreadex(NULL,0, LoadThumbNail16,(LPVOID)this,0/* CREATE_SUSPENDED*/,&m_dwThreadID);
  564. m_bRunning=true;
  565. }
  566. void ShowEffectDlg::OnButton2()
  567. {
  568. POSITION pos;
  569. pos=m_ListPNG.GetFirstSelectedItemPosition();
  570. if(pos==NULL)
  571. {
  572. return;
  573. }
  574. int selpos=m_ListPNG.GetNextSelectedItem(pos);
  575. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  576. CString str=m_AryPNGImgpaths.ElementAt(selpos);
  577. CString spath=str.Left (str.ReverseFind('\\')+1);
  578. spath+="s";
  579. spath+=str.Right (str.GetLength ()-str.ReverseFind ('\\')-1);
  580. spath.Replace ("png","jpg");
  581. ::DeleteFile(str); // 删除效果图中的jpg文件;
  582. ::DeleteFile(spath); // 删除效果图中的s的jpg文件;
  583. m_AryPNGImgpaths.RemoveAt(selpos);
  584. m_ListPNG.DeleteItem(selpos);
  585. m_nPNGIndex=0;
  586. m_nJPGIndex=0;
  587. }
  588. void ShowEffectDlg::OnLButtonDown(UINT nFlags, CPoint point)
  589. {
  590. // TODO: Add your message handler code here and/or call default
  591. // SetCapture();
  592. // m_startpt=point;
  593. CDialog::OnLButtonDown(nFlags, point);
  594. }
  595. void ShowEffectDlg::OnMouseMove(UINT nFlags, CPoint point)
  596. {
  597. // TODO: Add your message handler code here and/or call default
  598. /* if(GetCapture()!=this)return;
  599. if(m_rc.Width ()>m_rcscreen.Width ())
  600. {
  601. if(m_rc.left <m_rcscreen.left && point.x>m_startpt.x)
  602. {
  603. int dt=min(point.x-m_startpt.x, m_rcscreen.left-m_rc.left);
  604. m_rc.left +=dt;
  605. m_rc.right +=dt;
  606. }
  607. else if(m_rc.right >m_rcscreen.right && point.x<m_startpt.x)
  608. {
  609. int dt=min(m_startpt.x-point.x, m_rc.right-m_rcscreen.right);
  610. m_rc.left -=dt;
  611. m_rc.right -=dt;
  612. }
  613. }
  614. if(m_rc.Height ()>m_rcscreen.Height ())
  615. {
  616. if(m_rc.top <m_rcscreen.top && point.y>m_startpt.y)
  617. {
  618. int dt=min(point.y-m_startpt.y, m_rcscreen.top-m_rc.top);
  619. m_rc.top +=dt;
  620. m_rc.bottom +=dt;
  621. }
  622. else if(m_rc.bottom >m_rcscreen.bottom && point.y<m_startpt.y)
  623. {
  624. int dt=min(m_startpt.y-point.y, m_rc.bottom-m_rcscreen.bottom);
  625. m_rc.top -=dt;
  626. m_rc.bottom -=dt;
  627. }
  628. }
  629. m_startpt=point;
  630. RcChange();*/
  631. CDialog::OnMouseMove(nFlags, point);
  632. }
  633. void ShowEffectDlg::OnLButtonUp(UINT nFlags, CPoint point)
  634. {
  635. // TODO: Add your message handler code here and/or call default
  636. /* if(GetCapture()!=this)return;
  637. ReleaseCapture();*/
  638. CDialog::OnLButtonUp(nFlags, point);
  639. }
  640. BOOL ShowEffectDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
  641. {
  642. // TODO: Add your message handler code here and/or call default
  643. /* if(m_pImage==NULL)return 1;
  644. if(zDelta>0)
  645. {
  646. m_fscale*=1.2;
  647. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  648. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  649. m_rc.left -=dtx;
  650. m_rc.right +=dtx;
  651. m_rc.top -=dty;
  652. m_rc.bottom +=dty;
  653. }
  654. else
  655. {
  656. if(m_fscale<=1)return 1;
  657. m_fscale/=1.2;
  658. if(m_fscale<1)m_fscale=1;
  659. int dtx=(m_fscale*m_rcbak.Width ()-m_rc.Width ())/2.0;
  660. int dty=(m_fscale*m_rcbak.Height ()-m_rc.Height ())/2.0;
  661. m_rc.left -=dtx;
  662. m_rc.right +=dtx;
  663. m_rc.top -=dty;
  664. m_rc.bottom +=dty;
  665. if(m_rcbak.Height ()==m_rcscreen.Height ())
  666. {
  667. if(m_rc.top <m_rcscreen.top && m_rc.bottom < m_rcscreen.bottom )
  668. {
  669. dtx=m_rcscreen.bottom -m_rc.bottom;
  670. m_rc.top +=dtx;
  671. m_rc.bottom +=dtx;
  672. }
  673. else if(m_rc.top >m_rcscreen.top && m_rc.bottom > m_rcscreen.bottom )
  674. {
  675. dtx=m_rc.top-m_rcscreen.top;
  676. m_rc.top -=dtx;
  677. m_rc.bottom -=dtx;
  678. }
  679. dtx=m_rc.Width ();
  680. m_rc.left =(m_rcscreen.Width ()-dtx)/2;
  681. m_rc.right =m_rc.left +dtx;
  682. }
  683. if(m_rcbak.Width ()==m_rcscreen.Width ())
  684. {
  685. if(m_rc.left <m_rcscreen.left && m_rc.right < m_rcscreen.right )
  686. {
  687. dtx=m_rcscreen.right -m_rc.right;
  688. m_rc.left +=dtx;
  689. m_rc.right +=dtx;
  690. }
  691. else if(m_rc.left >m_rcscreen.left && m_rc.right > m_rcscreen.right )
  692. {
  693. dtx=m_rc.left-m_rcscreen.left;
  694. m_rc.left -=dtx;
  695. m_rc.right -=dtx;
  696. }
  697. dtx=m_rc.Height ();
  698. m_rc.top =(m_rcscreen.Height ()-dtx)/2;
  699. m_rc.bottom =m_rc.top +dtx;
  700. }
  701. }
  702. RcChange();*/
  703. return CDialog::OnMouseWheel(nFlags, zDelta, pt);
  704. }
  705. void ShowEffectDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
  706. {
  707. // TODO: Add your control notification handler code here
  708. POSITION pos;
  709. pos=m_ListPNG.GetFirstSelectedItemPosition();
  710. if(pos==NULL)
  711. {
  712. return;
  713. }
  714. m_nPNGIndex=m_ListPNG.GetNextSelectedItem(pos);
  715. m_bLoadPNG=1;
  716. MakeEffect();
  717. *pResult = 0;
  718. }
  719. void ShowEffectDlg::OnTimer(UINT nIDEvent)
  720. {
  721. // TODO: Add your message handler code here and/or call default
  722. KillTimer(nIDEvent);
  723. MakeEffect();
  724. }
  725. void ShowEffectDlg::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  726. {
  727. // TODO: Add your control notification handler code here
  728. POSITION pos;
  729. pos=m_ListJPG.GetFirstSelectedItemPosition();
  730. if(pos==NULL)
  731. {
  732. return;
  733. }
  734. m_nJPGIndex=m_ListJPG.GetNextSelectedItem(pos);
  735. m_bLoadJPG=1;
  736. MakeEffect();
  737. *pResult = 0;
  738. }
  739. int GetLengFromPt(CPoint pt1, CPoint pt2)
  740. {
  741. return (pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y);
  742. }
  743. int GetLengFromPt2(CPoint pt1, CPoint pt2)
  744. {
  745. return sqrt((float)(pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y));
  746. }
  747. void ShowEffectDlg::MakeEffect()
  748. {
  749. // Jeff.m_AryPNGImgpaths,客人原片\效果图\ 目录下的所有PNG图片;;
  750. if(m_AryPNGImgpaths.GetSize()==0)
  751. return;
  752. // m_pbmp:最终显示PNG效果图的Bimap对象(PNG+客人相片 合二为一的结果);
  753. if ( m_pImgFinalShow == NULL )
  754. return;
  755. Graphics graph(m_pImgFinalShow);
  756. // 将对象区域全部以透明色填充;
  757. graph.Clear(Color(255,255,255,255));
  758. if(m_bLoadJPG)
  759. {// 加载新的JPG相片;
  760. if(m_pImgJPG)
  761. delete m_pImgJPG;
  762. m_pImgJPG = NULL;
  763. }
  764. if(m_bLoadPNG)
  765. {// 加载新的PNG效果图;
  766. if(m_pImgPNG)
  767. delete m_pImgPNG;
  768. m_pImgPNG=NULL;
  769. if(m_pImgPNGbake)
  770. delete m_pImgPNGbake;
  771. m_pImgPNGbake=NULL;
  772. // m_pImage为显示的PNG效果图Bitmap对象;LoadImageFromBuf指定加载哪张PNG相片作为效果图显示;
  773. LoadImageFromBuf((Image**)&m_pImgPNG, m_AryPNGImgpaths.ElementAt(m_nPNGIndex));
  774. if(m_pPhotopatharray->GetSize())
  775. {
  776. GetRgn(m_pImgPNG);
  777. }
  778. m_pImgPNGbake = m_pImgPNG->Clone(0,0,m_pImgPNG->GetWidth(),m_pImgPNG->GetHeight(),PixelFormat32bppARGB );
  779. }
  780. int width,height;
  781. width=m_pImgPNG->GetWidth();
  782. height=m_pImgPNG->GetHeight();
  783. if(width==0 || height==0)
  784. return;
  785. InitRc(m_pImgPNG);
  786. CPoint pt1,pt2,pt3;
  787. int leng1,leng2,leng3;
  788. CPoint curpt;
  789. int leng;
  790. Graphics graph2(m_pImgPNG);
  791. // m_pPhotopatharray:客人的相片;
  792. if(m_pPhotopatharray->GetSize())
  793. {
  794. if(m_bLoadJPG)
  795. {// 加载顾客相片;
  796. LoadImageFromBuf(&m_pImgJPG, m_pPhotopatharray->ElementAt(m_nJPGIndex));
  797. }
  798. int i;
  799. for(int aa = 0; aa < RCARRARCOUNT; aa++)
  800. {
  801. leng1 = leng2 = leng3 = 10000000;
  802. for( i = 0; i < m_rcarray[aa].GetSize(); i += 2)
  803. {
  804. curpt.x = m_rcarray[aa].ElementAt(i);
  805. curpt.y = m_rcarray[aa].ElementAt(i+1);
  806. leng = GetLengFromPt(CPoint(0,0), curpt);
  807. if(leng<leng1)
  808. {
  809. leng1=leng;
  810. pt1=curpt;
  811. }
  812. leng=GetLengFromPt(CPoint(m_pImgPNG->GetWidth(),0), curpt);
  813. if(leng<leng2)
  814. {
  815. leng2=leng;
  816. pt2=curpt;
  817. }
  818. leng=GetLengFromPt(CPoint(0,m_pImgPNG->GetHeight()), curpt);
  819. if(leng<leng3)
  820. {
  821. leng3=leng;
  822. pt3=curpt;
  823. }
  824. }
  825. if(m_rcarray[aa].GetSize ())
  826. {
  827. pt1.x*=m_tempscale;
  828. pt1.y*=m_tempscale;
  829. pt2.x*=m_tempscale;
  830. pt2.y*=m_tempscale;
  831. pt3.x*=m_tempscale;
  832. pt3.y*=m_tempscale;
  833. Point destinationPoints[] = {
  834. Point(pt1.x, pt1.y), // destination for upper-left point of original
  835. Point(pt2.x, pt2.y), // destination for upper-right point of original
  836. Point(pt3.x, pt3.y) // destination for lower-left point of original
  837. };
  838. // graph2.DrawImage(m_pPhoto, destinationPoints, 3);
  839. int lengx=GetLengFromPt2(pt1, pt2);
  840. int lengy=GetLengFromPt2(pt1, pt3);
  841. /* CString ss;
  842. ss.Format("pt1:%d,%d pt2:%d,%d leng:%d", pt1.x, pt1.y,pt2.x, pt2.y,lengx);
  843. AfxMessageBox(ss);
  844. ss.Format("pt1:%d,%d pt3:%d,%d leng:%d", pt1.x, pt1.y,pt3.x, pt3.y,lengy);
  845. AfxMessageBox(ss);*/
  846. CRect rc(0,0,m_pImgJPG->GetWidth(),m_pImgJPG->GetHeight());
  847. RectFitDes(lengx,lengy,rc);
  848. graph2.DrawImage(
  849. m_pImgJPG,
  850. destinationPoints,
  851. 3,
  852. rc.left,
  853. rc.top,
  854. rc.Width(),
  855. rc.Height(),
  856. UnitPixel,
  857. NULL,
  858. NULL,
  859. NULL);
  860. }
  861. }
  862. ///////
  863. graph2.DrawImage(m_pImgPNGbake, 0, 0);
  864. }
  865. Rect destinationRect( m_rc.left , m_rc.top , m_rc.Width (), m_rc.Height () );
  866. graph.DrawImage(m_pImgPNG, destinationRect, 0,0,width,height,UnitPixel);
  867. CRect rc;
  868. GetClientRect(rc);
  869. rc.left +=110;
  870. rc.right -=110;
  871. InvalidateRect(rc);
  872. m_bLoadPNG=0;
  873. m_bLoadJPG=0;
  874. }
  875. // Jeff.pBmpImage2:被加载好的PNG效果相片;
  876. // 获取PNG效果图的透明区域;
  877. /************************************************************************/
  878. /*
  879. 函数:GetRgn
  880. 描述:获取指定Bitmap对象所表示的图像的透明区域;
  881. 参数:
  882. pImgPNG[IN] 要获取透明区域的Bitmap对象指针;
  883. 返回:
  884. 注意:
  885. */
  886. /************************************************************************/
  887. void ShowEffectDlg::GetRgn(IN Bitmap *pImgPNG)
  888. {
  889. m_tempscale=1.0;
  890. if(pImgPNG==NULL)return;
  891. // pBmpImage
  892. Bitmap *pBmpImage=NULL;
  893. BOOL bdelete=0;
  894. // .如果PNG效果相片长宽大于800
  895. // Bitemap::GetWidth() 获取此图像的图像高度,以像素为单位;
  896. if(pImgPNG->GetWidth()>800 || pImgPNG->GetHeight()>800)
  897. {
  898. bdelete=1;
  899. CRect rc(0,0,800,800);
  900. // GetWidth()的长度与CRect的长度是不一样的单位值,需要转换适合图片的比例;(一个是图片的像素尺寸,一个DC的大小尺寸)
  901. RectFitDes(pImgPNG->GetWidth(), pImgPNG->GetHeight(), rc);
  902. // 在适合图片长宽比例的显示设备中重新装载图片;
  903. pBmpImage=new Bitmap(rc.Width (), rc.Height (), PixelFormat32bppARGB );
  904. Graphics graphic(pBmpImage);
  905. graphic.Clear(Color(0,0,0,0));
  906. graphic.DrawImage(pImgPNG, 0,0,pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  907. m_tempscale=(float)pImgPNG->GetWidth()/(float)pBmpImage->GetWidth();
  908. }
  909. else
  910. pBmpImage=pImgPNG;
  911. // BitmapData这个类用于创建包含的信息来描述像素数据的位图图像的矩形区域的对象。
  912. BitmapData bitmapData;
  913. UINT* pixels;
  914. Rect rc(0, 0, pBmpImage->GetWidth(), pBmpImage->GetHeight() );
  915. // 指定格式读取pBmpImage里的图片像素到bitmapData中;
  916. pBmpImage->LockBits(
  917. rc, // 数据被加载到的区域;
  918. ImageLockModeRead, // 锁定方式:读或写;
  919. PixelFormat32bppARGB, // 数据保存的格式;
  920. &bitmapData); // 存储数据的对象;
  921. // Write to the temporary buffer provided by LockBits. RGB
  922. // Scan0:一个空指针到第一扫描线的开始
  923. pixels = (UINT*)bitmapData.Scan0;
  924. // Stride:
  925. // 一个INT值从位图区到下一个扫描线指定的字节数。这个值是负的自底向上的位图图像。
  926. DWORD wids=bitmapData.Stride/4; // 除以4,刚好为Color::alpha \red \green \blue 四色(只有PNG才有alpha色);
  927. Color color;
  928. Color color1,color2,color3,color4,color5,color6,color7,color8;
  929. // m_rcarray数组,用于记录PNG图片里的alpha色小于200的像素点坐标;
  930. BYTE R,G,B;
  931. for(int aa=0; aa<RCARRARCOUNT; aa++)
  932. m_rcarray[aa].RemoveAll(); // Jeff.清空以前的;
  933. for( INT row = 0; row < rc.Height; ++row)
  934. {
  935. for(INT col = 0; col < rc.Width-1; ++col)
  936. {
  937. // 将第一行取4个点填充color对象;
  938. color.SetValue(pixels[row * wids + col]);
  939. // Color::GetA() 方法获取此Color对象的alpha分量(返回这个颜色的alpha分量)。
  940. if(color.GetA() < 200)
  941. {
  942. CArray<int,int>*pArray=NULL;
  943. for(int aa=0; aa<RCARRARCOUNT; aa++)
  944. {
  945. if(m_rcarray[aa].GetSize() && pArray==NULL)
  946. {
  947. double x=m_rcarray[aa].ElementAt(0);
  948. double y=m_rcarray[aa].ElementAt(1);
  949. int x0=(int)x;
  950. int y0=(int)y;
  951. double dtx=col-x;
  952. double dty=row-y;
  953. if(abs(dtx)>abs(dty))
  954. {
  955. if(dty)
  956. {
  957. dtx/=abs(dty);
  958. dty/=abs(dty);
  959. }
  960. else if(dtx>0)
  961. dtx=1;
  962. else if(dtx<0)
  963. dtx=-1;
  964. }
  965. else
  966. {
  967. if(dtx)
  968. {
  969. dty/=abs(dtx);
  970. dtx/=abs(dtx);
  971. }
  972. else if(dty>0)
  973. dty=1;
  974. else if(dtx<0)
  975. dty=-1;
  976. }
  977. if(dtx>3)
  978. {
  979. double step=dtx/3.0;
  980. dtx/=step;
  981. dty/=step;
  982. }
  983. if(dty>3)
  984. {
  985. double step=dty/3.0;
  986. dtx/=step;
  987. dty/=step;
  988. }
  989. BOOL bFind=0;
  990. while(1)
  991. {
  992. x+=dtx;
  993. y+=dty;
  994. if(x>=(rc.Width-1) || x<1)break;
  995. if(y>=(rc.Height-1) || y<1)break;
  996. if(col>x0)
  997. {
  998. if(x<x0)
  999. {
  1000. break;
  1001. }
  1002. if(x>col)
  1003. {
  1004. break;
  1005. }
  1006. }
  1007. if(col<x0)
  1008. {
  1009. if(x>x0)
  1010. {
  1011. break;
  1012. }
  1013. if(x<col)
  1014. {
  1015. break;
  1016. }
  1017. }
  1018. if(row>y0)
  1019. {
  1020. if(y<y0)
  1021. {
  1022. break;
  1023. }
  1024. if(y>row)
  1025. {
  1026. break;
  1027. }
  1028. }
  1029. if(row<y0)
  1030. {
  1031. if(y>y0)
  1032. {
  1033. break;
  1034. }
  1035. if(y<row)
  1036. {
  1037. break;
  1038. }
  1039. }
  1040. color.SetValue(pixels[(int)y * wids + (int)x]);
  1041. if(color.GetA()==255)
  1042. {
  1043. color1.SetValue(pixels[(int)(y-1) * wids + (int)(x-1)]);
  1044. color2.SetValue(pixels[(int)(y-1) * wids + (int)(x-0)]);
  1045. color3.SetValue(pixels[(int)(y-1) * wids + (int)(x+1)]);
  1046. color4.SetValue(pixels[(int)(y-0) * wids + (int)(x-1)]);
  1047. color5.SetValue(pixels[(int)(y-0) * wids + (int)(x+1)]);
  1048. color6.SetValue(pixels[(int)(y+1) * wids + (int)(x-1)]);
  1049. color7.SetValue(pixels[(int)(y+1) * wids + (int)(x-0)]);
  1050. color8.SetValue(pixels[(int)(y+1) * wids + (int)(x+1)]);
  1051. 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)
  1052. {
  1053. bFind=1;
  1054. break;
  1055. }
  1056. }
  1057. }
  1058. if(bFind==0)
  1059. pArray=&(m_rcarray[aa]);
  1060. }
  1061. }
  1062. if(pArray==NULL)
  1063. {
  1064. BOOL bcontinue=1;
  1065. for(int yy=0; yy<RCARRARCOUNT; yy++)
  1066. {
  1067. if(m_rcarray[yy].GetSize()==0)
  1068. {
  1069. pArray=&(m_rcarray[yy]);
  1070. bcontinue=0;
  1071. break;
  1072. }
  1073. }
  1074. if(bcontinue)continue;
  1075. }
  1076. pArray->Add(col); // x坐标;
  1077. pArray->Add(row); // y坐标;
  1078. }
  1079. }
  1080. }
  1081. pBmpImage->UnlockBits(&bitmapData);
  1082. if(bdelete)delete pBmpImage;
  1083. }