123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737 |
- // ShowCut.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ShowCut.h"
- #include "JPEG.h"
- #include "MyLock.h"
- #include "ShowPhoto.h"
- #define THUMBNAIL_WIDTH 100
- #define THUMBNAIL_HEIGHT 90
- ShowCut::ShowCut(CWnd* pParent /*=NULL*/): CDialog(ShowCut::IDD, pParent)
- {
- m_bTerminate = false;
- m_bRunning = false;
- m_hThread = NULL;
- m_mode = 0;
- }
- void ShowCut::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- }
- BEGIN_MESSAGE_MAP(ShowCut, CDialog)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // ShowCut message handlers
- BOOL ShowCut::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
- GetClientRect(rc2);
- if (m_mode == 0)
- rc2.top += 35 * g_fscaley;
- else
- {
- GetDlgItem(IDC_BUTdelall)->ShowWindow(0);
- GetDlgItem(IDC_BUTdel)->ShowWindow(0);
- GetDlgItem(IDOK)->ShowWindow(0);
- }
- m_List1.MoveWindow(rc2);
- int right = rc2.right;
- GetDlgItem(IDOK)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- int hei = rc2.Height();
- int dtx = right - rc2.right - 5;
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDOK)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTdel)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdel)->MoveWindow(rc2);
- GetDlgItem(IDC_BUTdelall)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.top = 5;
- rc2.bottom = rc2.top + hei;
- rc2.left += dtx;
- rc2.right += dtx;
- GetDlgItem(IDC_BUTdelall)->MoveWindow(rc2);
- if (GetSize() == 0)
- {
- CDialog::OnCancel();
- return 0;
- }
- if (g_bAllBranch)
- {
- CString branchpath = GetBranchPhotoPath(m_branch);
- m_path = g_path1 + branchpath + "\\";
- }
- else
- m_path = g_path1 + "\\";
- m_path += m_strOrderNum;
- m_path += "\\";
- m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
- m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
- LoadPhotos();
- return TRUE;
- }
- unsigned __stdcall LoadThumbNail15(LPVOID lpParam)
- {
- try
- {
- ShowCut *pDlg = (ShowCut*)lpParam;
- CListCtrl *ListCtrl = &pDlg->m_List1;
- CImageList* pImgList = &pDlg->m_ImageListThumb;
- // reset our image list
- for (int i = 0; i < pImgList->GetImageCount(); i++)
- pImgList->Remove(i);
- // remove all items from list view
- ListCtrl->DeleteAllItems();
- pImgList->SetImageCount(pDlg->m_vFileName.size());
- TCHAR path[MAX_PATH];
- vector<CString>::iterator iter;
- // Set redraw to FALSE to avoid flickering during adding new items
- ListCtrl->SetRedraw(FALSE);
- int nIndex = 0;
- CString str, spath;
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- ListCtrl->InsertItem(nIndex, pDlg->m_titlearray.ElementAt(nIndex), nIndex);
- }
- ListCtrl->SetRedraw(TRUE);
- ListCtrl->Invalidate();
- const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
- int XDest, YDest, nDestWidth, nDestHeight;
- nIndex = 0;
- SolidBrush whitebrush(Color(255, 255, 255, 255));
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- // Load Image File
- Image *image = NULL;
- Bitmap *pBmp = NULL;
- str = *iter;
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (PathFileExists(spath))
- ::LoadImageFromBuf(&image, spath);
- else
- ::LoadImageFromBuf(&image, str);
- int orientation = GetOrientation(image);
- if (orientation == 8)
- image->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- image->RotateFlip(Rotate90FlipNone);
- if (image->GetWidth() == 0)
- continue;
- // Calculate Rect to fit to canvas
- const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
- if (fImgRatio > fRatio)
- {
- nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
- XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
- YDest = 0;
- nDestHeight = THUMBNAIL_HEIGHT;
- }
- else
- {
- XDest = 0;
- nDestWidth = THUMBNAIL_WIDTH;
- nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
- YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
- }
- pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
- Graphics graph2(pBmp);
- graph2.Clear(Color(255, 192, 192, 192));
- graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
- Graphics graph(pBmp);
- Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
- // Draw Image
- graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
- float scale = (float)nDestWidth / (float)image->GetWidth();
- int pos = pDlg->FindArray2(pDlg->m_titlearray.ElementAt(nIndex));
- if (pos != -1)
- {
- int nIndex = pos;
- CRect rc = pDlg->m_rcarray.ElementAt(nIndex);
- int wid = pDlg->m_widtharray.ElementAt(nIndex).left;
- int hei = pDlg->m_widtharray.ElementAt(nIndex).top;
- scale *= (float)image->GetWidth() / (float)wid;
- rc.left *= scale;
- rc.right *= scale;
- rc.top *= scale;
- rc.bottom *= scale;
- rc.left += XDest;
- rc.right += XDest;
- rc.top += YDest;
- rc.bottom += YDest;
- Pen blackPen(Color(255, 255, 0, 0), 1);
- graph.DrawRectangle(&blackPen, rc.left, rc.top, rc.Width(), rc.Height());
- }
- delete image;
- // Attach to Bitmap and Replace image in CImageList
- CBitmap bitmap;
- HBITMAP hbmp;
- pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
- bitmap.Attach(hbmp);
- pImgList->Replace(nIndex, &bitmap, NULL);
- delete pBmp;
- // Redraw only a current item for removing flickering and fast speed.
- ListCtrl->RedrawItems(nIndex, nIndex);
- // Release used DC and Object
- }
- ListCtrl->Invalidate();
- pDlg->m_bRunning = false;
- pDlg->m_bTerminate = false;
- _endthreadex(0);
- return 0;
- }
- catch (...)
- {
- }
- return true;
- }
- void ShowCut::LoadThumbImages()
- {
- TerminateThread();
- m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail15, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
- m_bRunning = true;
- }
- BOOL ShowCut::TerminateThread()
- {
- if (!m_bRunning)
- return TRUE;
- m_bTerminate = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
- break;
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- return TRUE;
- }
- void ShowCut::OnDestroy()
- {
- TerminateThread();
- CDialog::OnDestroy();
- }
- void ShowCut::LoadPhotos()
- {
- if (m_bRunning)
- return;
- #ifdef USE_KERNEL_DLL
- DWORD dwMemSize = 0;
- CStringArray AryLoadExtImgpath;
- CStringArray AryWithExtImgpath;
- CStringArray AryOrderDirectory;
- CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
- INT i = 0;
- INT nSize = 0;
- INT nIndex = 0;
- CString str;
- CString strfilename;
- CStringArray AryImgNums;
- CStringArray AryCropName;
- AryImgNums.Copy(m_noarray);
- AryCropName.Copy(m_namearray);
- if ( GetOrderImgpathEx(EImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.jpg|*.jpeg"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory))
- {// 先查找初修片;
- m_patharray1.RemoveAll();
- nSize = AryLoadExtImgpath.GetSize();
- for (i = 0; i < nSize; i++ )
- {
- // 过滤小图和中图;
- str = AryLoadExtImgpath.ElementAt(i);
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (strfilename.Find(_T(".")) != -1)
- {
- strfilename = strfilename.Left(strfilename.Find(_T(".")));
- do
- {
- nIndex = FindArray(&AryImgNums, strfilename);
- if ( nIndex != -1 )
- {// 是要显示的裁剪相片;
- m_patharray1.Add(str);
- m_titlearray.Add(strfilename + _T("\r\n") + AryCropName.ElementAt(nIndex));
- AryCropName.RemoveAt(nIndex);
- AryImgNums.RemoveAt(nIndex);
- }
- } while ( FindArray(&AryImgNums, strfilename) != -1 );
- }
- }
- }
- // 查找完初修片后,再次查找原片;
- AryLoadExtImgpath.RemoveAll();
- AryWithExtImgpath.RemoveAll();
- AryOrderDirectory.RemoveAll();
- if ( GetOrderImgpathEx(OImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.jpg|*.jpeg"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory))
- {// 查找原片;
- nSize = AryLoadExtImgpath.GetSize();
- for (i = 0; i < nSize; i++ )
- {
- str = AryLoadExtImgpath.ElementAt(i);
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- strfilename = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (strfilename.Find(_T(".")) != -1)
- {
- strfilename = strfilename.Left(strfilename.Find(_T(".")));
- do
- {
- nIndex = FindArray(&AryImgNums, strfilename);
- if ( nIndex != -1 )
- {// 是要显示的裁剪相片;
- m_patharray1.Add(str);
- m_titlearray.Add(strfilename + _T("\r\n") + AryCropName.ElementAt(nIndex));
- AryCropName.RemoveAt(nIndex);
- AryImgNums.RemoveAt(nIndex);
- }
- } while ( FindArray(&AryImgNums, strfilename) != -1 );
- }
- }
- }
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for ( i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- if (m_vFileName.size())
- LoadThumbImages();
- #else
- m_patharray1.RemoveAll();
- m_path.MakeLower();
- CStringArray dirarray;
- CString str, path2, no;
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- str.MakeLower();
- if (str == m_path)continue;
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- }
- if (1)
- {
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();coo.end() != it;it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- path2 = str;
- path2.Replace("客户原片", "修好的片");
- int pos1 = path2.Find(m_strOrderNum);
- pos1 += m_strOrderNum.GetLength();
- int pos2 = path2.ReverseFind('\\');
- path2 = path2.Left(pos1) + path2.Right(path2.GetLength() - pos2);
- no = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- no = no.Left(no.Find("."));
- CStringArray noarray, namearray;
- noarray.Copy(m_noarray);
- namearray.Copy(m_namearray);
- int pos = ::FindArray(&noarray, no);
- while (pos != -1)
- {
- if (::PathFileExists(path2))
- {
- m_patharray1.Add(path2);
- }
- else
- {
- m_patharray1.Add(str);
- }
- m_titlearray.Add(no + "\r\n" + namearray.ElementAt(pos));
- noarray.RemoveAt(pos); namearray.RemoveAt(pos);
- pos = ::FindArray(&noarray, no);
- }
- }
- }
- }
- if (m_patharray1.GetSize() == 0 && m_mode)
- {
- if (m_mode == 2)
- AfxMessageBox("无照片裁剪!");
- CDialog::OnCancel();
- return;
- }
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- #endif
- }
- void ShowCut::OnBUTdelall()
- {
- if (AfxMessageBox("清除裁剪后将无法恢复, 确认清除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)
- return;
- CString sql;
- sql.Format("update dindan set size='' where id='%s'", m_strOrderNum);
- g_sendhead.bsql = 1;
- if (m_branch != "" && g_bAllBranch)
- {
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect();
- g_bBranchModify = 0;
- g_branchip = g_branchname = "";
- }
- else
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!");
- GetSize();
- LoadPhotos();
- }
- void ShowCut::OnBUTdel()
- {
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- AfxMessageBox("请先选中您要清除裁剪的照片!", MB_ICONINFORMATION);
- return;
- }
- if (AfxMessageBox("清除裁剪后将无法恢复, 确认清除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- int iItem = m_List1.GetNextSelectedItem(pos);
- CString title = m_List1.GetItemText(iItem, 0);
- CString no = title.Left(title.Find("\r"));
- CString name = title.Right(title.GetLength() - title.ReverseFind('\n') - 1);
- {
- CString header = no + ":" + name + ",";
- int pos = m_size.Find(header);
- if (pos != -1)
- {
- CString left, right;
- left = m_size.Left(pos);
- m_size = m_size.Right(m_size.GetLength() - pos - header.GetLength());
- pos = m_size.Find(";");
- right = m_size.Right(m_size.GetLength() - pos - 1);
- m_size = left + right;
- }
- }
- CString sql;
- sql.Format("update dindan set size='%s' where id='%s'", m_size, m_strOrderNum);
- g_sendhead.bsql = 1;
- if (m_branch != "" && g_bAllBranch)
- {
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- g_pMainWnd->OnDisconnect();
- g_bBranchModify = 0;
- g_branchip = g_branchname = "";
- }
- else
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!");
- GetSize();
- LoadPhotos();
- }
- void ShowCut::AddSize(CString size)
- {
- int pos = size.Find(":");
- if (pos != -1)
- {
- CString str;
- CRect rc;
- str = size.Left(pos);
- // 添加相片名称;
- m_noarray.Add(str);
- str = size.Right(size.GetLength() - pos - 1);
- pos = str.Find(",");
- // 添加裁剪方案名;
- m_namearray.Add(str.Left(pos));
- str.Delete(0, pos + 1);
- pos = str.Find(",");
- rc.left = atoi(str.Left(pos)); str.Delete(0, pos + 1);
- pos = str.Find(",");
- rc.top = atoi(str.Left(pos)); str.Delete(0, pos + 1);
- m_widtharray.Add(rc);
- pos = str.Find(",");
- rc.left = atoi(str.Left(pos)); str.Delete(0, pos + 1);
- pos = str.Find(",");
- rc.top = atoi(str.Left(pos)); str.Delete(0, pos + 1);
- pos = str.Find(",");
- rc.right = atoi(str.Left(pos)); str.Delete(0, pos + 1);
- rc.bottom = atoi(str);
- // 添加裁剪坐标;
- m_rcarray.Add(rc);
- }
- }
- BOOL ShowCut::GetSize() // 获取裁剪的相片坐标;
- {
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 11;
- g_sendhead.tabcount = 1;
- CString filter = "id='" + m_strOrderNum + "';";
- if (m_branch != "")
- {
- g_branchip = GetIP(m_branch);
- g_pMainWnd->OnDisconnect();
- g_branchname = m_branch;
- g_bBranchModify = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- g_pMainWnd->OnDisconnect();
- g_bBranchModify = 0;
- g_branchip = g_branchname = "";
- }
- else
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)
- {
- return 0;
- }
- CArray<CStringArray, CStringArray>m_List1array;
- DataToArray(&m_List1array);
- CenterWindow();
- m_noarray.RemoveAll();
- m_widtharray.RemoveAll();
- m_rcarray.RemoveAll();
- if (m_List1array.GetSize())
- {
- m_size = m_List1array.ElementAt(0).ElementAt(60);//
- int pos = m_size.Find(";");
- while (pos != -1)
- {
- // 添加裁剪的相片;
- AddSize(m_size.Left(pos));
- m_size = m_size.Right(m_size.GetLength() - pos - 1);
- pos = m_size.Find(";");
- }
- m_size = m_List1array.ElementAt(0).ElementAt(60);
- return 1;
- }
- return 0;
- }
- int ShowCut::FindArray2(CString title)
- {
- CString no = title.Left(title.Find("\r"));
- CString name = title.Right(title.GetLength() - title.ReverseFind('\n') - 1);
- for (int i = 0; i < m_noarray.GetSize(); i++)
- {
- if (no == m_noarray.ElementAt(i) && name == m_namearray.ElementAt(i))
- return i;
- }
- return -1;
- }
- void ShowCut::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) // 双击裁剪小图查看大图效果;
- {
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- Image *image = NULL;
- if (m_patharray1.GetSize() <= iItem)return;
- CString str = m_patharray1.ElementAt(iItem);
- ::LoadImageFromBuf(&image, str);
- int orientation = GetOrientation(image);
- if (orientation == 8)
- image->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- image->RotateFlip(Rotate90FlipNone);
- if (image->GetWidth() == 0)
- return;
- Graphics graph(image);
- // Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
- // Draw Image
- // graph.DrawImage(image, desRect, 0,0,image->GetWidth(),image->GetHeight(),UnitPixel);
- float scale = 1.0;//(float)nDestWidth/(float)image->GetWidth();
- int pos2 = FindArray2(m_titlearray.ElementAt(iItem));
- if (pos2 != -1)
- {
- int nIndex = pos2;
- CRect rc = m_rcarray.ElementAt(nIndex);
- int wid = m_widtharray.ElementAt(nIndex).left;
- int hei = m_widtharray.ElementAt(nIndex).top;
- scale *= (float)image->GetWidth() / (float)wid;
- rc.left *= scale;
- rc.right *= scale;
- rc.top *= scale;
- rc.bottom *= scale;
- /* rc.left +=XDest ;
- rc.right +=XDest;
- rc.top +=YDest ;
- rc.bottom +=YDest ;*/
- Pen blackPen(Color(255, 255, 0, 0), 1);
- graph.DrawRectangle(&blackPen, rc.left, rc.top, rc.Width(), rc.Height());
- ShowPhoto dlg;
- dlg.m_pImg = image;
- dlg.DoModal();
- }
- delete image;
- *pResult = 0;
- }
|