⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leftimageview.cpp

📁 数字摄影测量相关算法编程,在VC环境下实现影像特征点提取.
💻 CPP
字号:
// LeftImageView.cpp : implementation file
//

#include "stdafx.h"
#include "GaMatch.h"
#include "LeftImageView.h"
#include "windows.h"
#include "windowsx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CPoint CurPt;
extern int matchi,matchj;
extern short SizeMatch;
extern short SizeSearch;
extern short nTask;//任务
/////////////////////////////////////////////////////////////////////////////
// CLeftImageView

IMPLEMENT_DYNCREATE(CLeftImageView, CScrollView)

CLeftImageView::CLeftImageView()
{
}

CLeftImageView::~CLeftImageView()
{
}


BEGIN_MESSAGE_MAP(CLeftImageView, CScrollView)
	//{{AFX_MSG_MAP(CLeftImageView)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLeftImageView drawing

void CLeftImageView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();
	ASSERT(GetDocument() != NULL);
	CGaMatchDoc* pDoc =(CGaMatchDoc*) GetDocument();
	SetScrollSizes(MM_TEXT, pDoc->GetLImgSize(pDoc->d_choice));
}

void CLeftImageView::OnDraw(CDC* pDC)
{
	pDoc =(CGaMatchDoc*) GetDocument();
	LPRECT lpRect;
	RECT   rect;
    POINT  pt;
	double x0,y0;
	HDIB  hDIB;
	lpRect=▭
	GetClientRect(lpRect);
    pt=GetDeviceScrollPosition();
	x0=pt.x/pDoc->ZoomFractor;
	y0=pt.y/pDoc->ZoomFractor;	    
	hDIB = pDoc->GetLImage(pDoc->d_choice);
	if (hDIB != NULL)
	{
		LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
		int cxDIB = (int) ::DIBWidth(lpDIB);         // Size of DIB - x
		int cyDIB = (int) ::DIBHeight(lpDIB);        // Size of DIB - y
		::GlobalUnlock((HGLOBAL) hDIB);
		CRect rcDIB;
		
		rcDIB.top = rcDIB.left = 0;
		rcDIB.right = cxDIB;
		rcDIB.bottom = cyDIB;
	
		CRect rcDest;
		if (pDC->IsPrinting())   // printer DC
		{
			// get size of printer page (in pixels)
			int cxPage = pDC->GetDeviceCaps(HORZRES);
			int cyPage = pDC->GetDeviceCaps(VERTRES);
			// get printer pixels per inch
			int cxInch = pDC->GetDeviceCaps(LOGPIXELSX);
			int cyInch = pDC->GetDeviceCaps(LOGPIXELSY);
			rcDest.top = rcDest.left = 0;
			rcDest.bottom = (int)(((double)cyDIB * cxPage * cyInch)
					/ ((double)cxDIB * cxInch));
			rcDest.right = cxPage;
		}
		else   // not printer DC
		{
			rcDest.top=rcDest.left=0;
			rcDest.bottom=(long)(pDoc->ZoomFractor*rcDIB.bottom);
			rcDest.right =(long)(pDoc->ZoomFractor*rcDIB.right);
			
		}
		::PaintDIB(pDC->m_hDC, &rcDest, pDoc->GetLImage(pDoc->d_choice),
			&rcDIB, pDoc->GetLImgPalette(pDoc->d_choice));
		pDC->SetROP2(R2_BLACK);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CLeftImageView diagnostics

#ifdef _DEBUG
void CLeftImageView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CLeftImageView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CLeftImageView message handlers

/*
void CLeftImageView::OnAverWave2() 
{
	pDoc =(CGaMatchDoc*) GetDocument();
	HDIB hDIB = pDoc->GetLImage(pDoc->d_choice);
//	HDIB hDIB = pDoc->GetHDIB();
	unsigned char *ii,*oi;	
    LPSTR pDIB;
	long Col,Row,i,j;
	int n=5,yy,xx,n2,sum;
	n2=(n-1)/2;
	if (hDIB != NULL)
		{
			pDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB);
			ii=(unsigned char *)::FindDIBBits(pDIB);				
			Row=::DIBWidth(pDIB);								
			Col=::DIBHeight(pDIB);							
			::GlobalUnlock((HGLOBAL) hDIB);
		}
    oi =(unsigned char *) GlobalAllocPtr(GHND,Row*Col);if(!oi)return ;
    for(i=0;i<Col;i++) { for(j=0;j<Row;j++){oi[i*Row+j]=0;}}

    for(i=n2;i<Col-n2;i++){
		for(j=n2;j<Row-n2;j++){sum=0;
		for(yy=i-n2;yy<=i+n2;yy++){for(xx=j-n2;xx<=j+n2;xx++){sum += ii[yy*Row+xx];}}
		  oi[i*Row+j]=(int)((float)sum/(n*n)+.5);
		  }
     }

	for(i=0;i<Row*Col;i++)ii[i]=oi[i];	
	Invalidate(FALSE);	
	GlobalFreePtr(oi);
	return;	
}
*/

void CLeftImageView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CDC* dc=GetDC();
	static int num=1;
	int x,y,cxDIB,cyDIB;
	int i,j;
	LPSTR lpDIB;
//	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CPoint pt0=GetDeviceScrollPosition();
	x=pt0.x+point.x;
	y=pt0.y+point.y;
	CPen pen(PS_SOLID,1,RGB(255,0,0));
	dc->SelectObject(&pen);
	dc->MoveTo(point.x-5,point.y);
	dc->LineTo(point.x+5,point.y);
	dc->MoveTo(point.x,point.y-5);
	dc->LineTo(point.x,point.y+5);
	char string[30];
	sprintf(string,"%d",num);
    dc->TextOut(point.x+5,point.y+5,string);
	num++;

    if(nTask==10)		
        pDoc->GoodChooseGa(x,y);
	CScrollView::OnLButtonDown(nFlags, point);
}

void CLeftImageView::OnMouseMove(UINT nFlags, CPoint point) 
{
	short nNewXPos=GetDeviceScrollPosition().x;
	short nNewYPos=GetDeviceScrollPosition().y;
	CStatusBar* pStatusBar=
	  (CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(
	                                          AFX_IDW_STATUS_BAR);
	char out1[25];
 	wsprintf(out1,"鼠标位置(%i,%i)",point.x,point.y);
	pStatusBar->SetPaneText(0,out1);	
	CScrollView::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -