123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- // ComparePhoto.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "ComparePhoto.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- CComparePhoto::CComparePhoto(CWnd* pParent /*=NULL*/)
- : CDialog(CComparePhoto::IDD, pParent)
- {
- m_pImage = m_pImage2 = m_pImage3 = m_pImage4 = NULL;
- }
- void CComparePhoto::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CComparePhoto, CDialog)
- //{{AFX_MSG_MAP(CComparePhoto)
- ON_WM_PAINT()
- ON_WM_DESTROY()
- ON_WM_ERASEBKGND()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- BOOL CComparePhoto::OnEraseBkgnd(CDC* pDC)
- {
- return 1;
- }
- BOOL CComparePhoto::OnInitDialog()
- {
- CDialog::OnInitDialog();
- ::LoadImageFromBuf(&m_pImage, m_path1);
- ::LoadImageFromBuf(&m_pImage2, m_path2);
- if (m_path3 != "")::LoadImageFromBuf(&m_pImage3, m_path3);
- if (m_path4 != "")::LoadImageFromBuf(&m_pImage4, m_path4);
- int orientation = GetOrientation(m_pImage);
- if (orientation == 8)
- {
- m_pImage->RotateFlip(Rotate270FlipNone);
- }
- else if (orientation == 6)
- {
- m_pImage->RotateFlip(Rotate90FlipNone);
- }
- orientation = GetOrientation(m_pImage2);
- if (orientation == 8)
- {
- m_pImage2->RotateFlip(Rotate270FlipNone);
- }
- else if (orientation == 6)
- {
- m_pImage2->RotateFlip(Rotate90FlipNone);
- }
- orientation = GetOrientation(m_pImage3);
- if (orientation == 8)
- {
- m_pImage3->RotateFlip(Rotate270FlipNone);
- }
- else if (orientation == 6)
- {
- m_pImage3->RotateFlip(Rotate90FlipNone);
- }
- orientation = GetOrientation(m_pImage4);
- if (orientation == 8)
- {
- m_pImage4->RotateFlip(Rotate270FlipNone);
- }
- else if (orientation == 6)
- {
- m_pImage4->RotateFlip(Rotate90FlipNone);
- }
- ::SetWindowPos(m_hWnd, HWND_TOP, 0, 0, g_screenwid, g_screenhei, SWP_SHOWWINDOW);
- return TRUE;
- }
- void CComparePhoto::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- try
- {
- CRect rc, rc2, rc3, rc4;
- GetClientRect(rc);
- rc2 = rc;
- int wid = rc.Width();
- int hei = rc.Height();
- if (m_pImage && m_pImage2 && m_pImage3 == NULL)
- {
- rc.right -= wid / 2;
- rc2.left += wid / 2 - 2;
- Graphics graph(dc.GetSafeHdc());
- graph.Clear(Color(255, 0, 0, 0));
- int width = m_pImage->GetWidth();
- int height = m_pImage->GetHeight();
- RectFitDes(width, height, rc);
- Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
- graph.DrawImage(m_pImage, destinationRect, 0, 0, width, height, UnitPixel);
- width = m_pImage2->GetWidth();
- height = m_pImage2->GetHeight(); RectFitDes(width, height, rc2);
- Rect destinationRect2(rc2.left, rc2.top, rc2.Width(), rc2.Height());
- graph.DrawImage(m_pImage2, destinationRect2, 0, 0, width, height, UnitPixel);
- }
- else if (m_pImage && m_pImage2 && m_pImage3)
- {
- rc3 = rc; rc4 = rc;
- rc.right -= wid / 2;
- rc.bottom -= hei / 2;
- rc2.left += wid / 2 - 2;
- rc2.bottom = rc.bottom;
- rc3.top = rc.bottom;
- rc4.top = rc.bottom;
- rc3.right = rc.right;
- rc4.left = rc2.left;
- Graphics graph(dc.GetSafeHdc());
- graph.Clear(Color(255, 0, 0, 0));
- int width = m_pImage->GetWidth();
- int height = m_pImage->GetHeight();
- RectFitDes(width, height, rc);
- Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height());
- graph.DrawImage(m_pImage, destinationRect, 0, 0, width, height, UnitPixel);
- width = m_pImage2->GetWidth();
- height = m_pImage2->GetHeight(); RectFitDes(width, height, rc2);
- Rect destinationRect2(rc2.left, rc2.top, rc2.Width(), rc2.Height());
- graph.DrawImage(m_pImage2, destinationRect2, 0, 0, width, height, UnitPixel);
- if (m_pImage3)
- {
- width = m_pImage3->GetWidth();
- height = m_pImage3->GetHeight(); RectFitDes(width, height, rc3);
- Rect destinationRect2(rc3.left, rc3.top, rc3.Width(), rc3.Height());
- graph.DrawImage(m_pImage3, destinationRect2, 0, 0, width, height, UnitPixel);
- }
- if (m_pImage4)
- {
- width = m_pImage4->GetWidth();
- height = m_pImage4->GetHeight(); RectFitDes(width, height, rc4);
- Rect destinationRect2(rc4.left, rc4.top, rc4.Width(), rc4.Height());
- graph.DrawImage(m_pImage4, destinationRect2, 0, 0, width, height, UnitPixel);
- }
- }
- else
- {
- // dc.FillSolidRect (rc, 0);
- }
- }
- catch (...)
- {
- }
- // Do not call CDialog::OnPaint() for painting messages
- }
- void CComparePhoto::OnDestroy()
- {
- if (m_pImage)delete m_pImage;
- if (m_pImage2)delete m_pImage2;
- if (m_pImage3)delete m_pImage3;
- if (m_pImage4)delete m_pImage4;
- CDialog::OnDestroy();
- }
|