📄 arithprocession.cpp
字号:
// ArithProcession.cpp : implementation file
//
#include "stdafx.h"
#include "FingerDemo.h"
#include "ArithProcession.h"
#include "fingerdll.h"
#include "drawminutia.h"
#include "scandialog.h"
#include "zhongzhgetbmp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CArithProcession
extern CFingerDemoApp theApp;
IMPLEMENT_DYNCREATE(CArithProcession, CFormView)
CArithProcession::CArithProcession()
: CFormView(CArithProcession::IDD)
{
//{{AFX_DATA_INIT(CArithProcession)
m_cenx = 0;
m_ceny = 0;
m_nTzhdNum = 0;
m_sQuality = _T("");
m_sFingerType = _T("");
//}}AFX_DATA_INIT
sbmp1=new Scan_Bmp();
sbmp2=new Scan_Bmp();
sbmp2->ReadFile(theApp.m_ProgramePath+"\\Sampleb.bmp");
sbmp1->ReadFile(theApp.m_ProgramePath+"\\Samplea.bmp");
m_Minutia=(unsigned char*)GlobalAlloc(GMEM_FIXED,MAXNUM*DIM+4);
quli=type=0;
cenx=ceny=0;
theApp.m_pProcessionView=this;
}
CArithProcession::~CArithProcession()
{
GlobalFree(m_Minutia);
theApp.m_bProcession=false;
delete sbmp1;
delete sbmp2;
}
void CArithProcession::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CArithProcession)
DDX_Control(pDX, IDC_FINGER_BMP4, m_Image4);
DDX_Control(pDX, IDC_FINGER_BMP3, m_Image3);
DDX_Control(pDX, IDC_FINGER_BMP2, m_Image2);
DDX_Control(pDX, IDC_FINGER_BMP1, m_Image1);
DDX_Text(pDX, IDC_IMAGE_CENTERX, m_cenx);
DDX_Text(pDX, IDC_IMAGE_CENTERY, m_ceny);
DDX_Text(pDX, IDC_TZHD_NUM, m_nTzhdNum);
DDX_Text(pDX, IDC_QUALITY_NUM, m_sQuality);
DDX_Text(pDX, IDC_FINGER_TYPE, m_sFingerType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CArithProcession, CFormView)
//{{AFX_MSG_MAP(CArithProcession)
ON_BN_CLICKED(IDC_INPORT_BMPFILE, OnInportBmpfile)
ON_BN_CLICKED(IDC_INPORT_CAPTURE, OnInportCapture)
ON_BN_CLICKED(IDC_COMPUTE_CENTER, OnComputeCenter)
ON_BN_CLICKED(IDC_LU_BO, OnLuBo)
ON_BN_CLICKED(IDC_THINNER, OnThinner)
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CArithProcession diagnostics
#ifdef _DEBUG
void CArithProcession::AssertValid() const
{
CFormView::AssertValid();
}
void CArithProcession::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CArithProcession message handlers
void CArithProcession::OnInportBmpfile()
{
// TODO: Add your control notification handler code here
CFileDialog fg(TRUE, // TRUE for FileOpen, FALSE for FileSaveAs
"*.bmp",
NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"位图文件(*.bmp)|*.bmp",
this);
if(fg.DoModal() == IDOK)
{
CString fn;
fn=fg.GetFileName();
Scan_Bmp *tmp=new Scan_Bmp();
tmp->ReadFile(fn);
sbmp1->ExtendSmallBmp(tmp);
CPaintDC dc(this); // device context for painting
sbmp1->DrawDib(m_Image1.GetDC(),1,0,0);
}
if(!GetMinutia(sbmp1->m_Bmp_pBmpValue,NULL,sbmp1->m_Height,sbmp1->m_Width ,m_Minutia,quli,type,cenx,ceny))
{
MessageBox("指纹图像不合格","注意",MB_OK);
return;
}
}
void CArithProcession::OnInportCapture()
{
// TODO: Add your control notification handler code here
if(theApp.cap_type==1)//////////光电指纹采集仪采集图像/////////////////////
{
CScanDialog gfr(sbmp1);
if(gfr.DoModal()==IDOK)
{
if(!GetMinutia(sbmp1->m_Bmp_pBmpValue,NULL,sbmp1->m_Height,sbmp1->m_Width ,m_Minutia,quli,type,cenx,ceny))
{
MessageBox("指纹图像不合格","注意",MB_OK);
return;
}
RECT rc;
GetDlgItem(IDC_FINGER_BMP1)->GetWindowRect(&rc);
InvalidateRect(&rc);
}
}
else if(theApp.cap_type==2)/////////////电容传感器采集指纹图像////////////
{
CZhongzhGetBmp zz;
zz.GetBmp(sbmp1);
if(!GetMinutia(sbmp1->m_Bmp_pBmpValue,NULL,sbmp1->m_Height,sbmp1->m_Width ,m_Minutia,quli,type,cenx,ceny))
{
MessageBox("指纹图像不合格","注意",MB_OK);
return;
}
RECT rc;
GetDlgItem(IDC_FINGER_BMP1)->GetWindowRect(&rc);
InvalidateRect(&rc);
}
}
void CArithProcession::OnComputeCenter()
{
// TODO: Add your control notification handler code here
if(!ComputeCenterAndCut(sbmp1->m_Bmp_pBmpValue,sbmp2->m_Bmp_pBmpValue,sbmp1->m_Height,sbmp1->m_Width,cenx,ceny))
{
MessageBox("指纹图像不合格","注意",MB_OK);
return;
}
sbmp2->DrawDib(m_Image2.GetDC(),1,0,0);
Draw_Direction_Round(m_Image2.m_hWnd,m_Image2.GetDC(),cenx,256-ceny,0,0,0,200,256,200,256,RGB(255,0,0),RGB(255,255,0),FALSE);
this->m_cenx=cenx;
this->m_ceny=ceny;
UpdateData(false);
GetDlgItem(IDC_IMAGE_CENTERX)->UpdateWindow();
GetDlgItem(IDC_IMAGE_CENTERY)->UpdateWindow();
}
void CArithProcession::OnLuBo()
{
// TODO: Add your control notification handler code here
if(!ImageFilter(sbmp1->m_Bmp_pBmpValue,sbmp2->m_Bmp_pBmpValue,sbmp1->m_Height,sbmp1->m_Width))
{
MessageBox("指纹图像不合格","注意",MB_OK);
return;
}
sbmp2->DrawDib(m_Image3.GetDC(),1,0,0);
switch(this->quli)
{
case 1:
this->m_sQuality="优";
break;
case 2:
this->m_sQuality="良";
break;
case 3:
this->m_sQuality="一般";
break;
}
switch(type)
{
case 1:
this->m_sFingerType="左箕型";
break;
case 2:
this->m_sFingerType="右箕型";
break;
case 3:
this->m_sFingerType="斗型";
break;
case 4:
this->m_sFingerType="弓型";
break;
case 5:
this->m_sFingerType="杂型";
break;
}
UpdateData(false);
}
void CArithProcession::OnThinner()
{
// TODO: Add your control notification handler code here
if(!GetMinutia(sbmp1->m_Bmp_pBmpValue,sbmp2->m_Bmp_pBmpValue,sbmp1->m_Height,sbmp1->m_Width ,m_Minutia,quli,type,cenx,ceny))
{
MessageBox("第一枚指纹图像不合格","注意",MB_OK);
return;
}
MINUTIASTRU tm[MAXNUM],bad[MAXNUM];
CENTER core1;
// m_centerx=cenx;m_centery=ceny;
core1.x=cenx;core1.y=IMAGEHEIGHT-ceny;
int num1=0;
for(int rcl = 0; rcl <m_Minutia[0]; rcl++)
{
tm[rcl].x = m_Minutia[rcl*DIM+4];
tm[rcl].y = m_Minutia[rcl*DIM+5];
tm[rcl].direction = m_Minutia[rcl*DIM+6]*2;
if(m_Minutia[rcl*DIM+7]>0)
{
bad[num1].x = m_Minutia[rcl*DIM+4];
bad[num1].y = m_Minutia[rcl*DIM+5];
bad[num1].direction =m_Minutia[rcl*DIM+6]*2;
num1++;
}
}
sbmp2->DrawDib(m_Image4.GetDC(),1,0,0);
DrawMinutia(
this->m_Image4.m_hWnd ,//HWND hWnd, //父窗口句柄
this->m_Image4.GetDC(),//CDC *pDC, //父窗口DC
0,//short x, //图象的位置(相对于父窗口的左上角)
0,//short y,
200,
256,
sbmp2->m_Bmp_pBmpValue , //256灰度的图象数据
200,
256,
m_Minutia[0], //特征点个数
tm,//MINUTIASTRU *lpMinutia1, //特征点结构数组
0,//short MinutiaNum2,
NULL,//MINUTIASTRU *lpMinutia2,
num1,//short MinutiaNum2,
bad,//MINUTIASTRU *lpMinutia2,
// 0,//short MinutiaNum3,
// NULL,//MINUTIASTRU *lpMinutia3,
&core1,//NULL,//CENTER *lpMainCenter, //主中心结构指针
NULL,//CENTER *lpAidCenter, //副中心结构指针
NULL,//DELTA *lpLeftDelta, //左三角结构指针
NULL,//DELTA *lpRightDelta, //右三角结构指针
TRUE//bool whetherDraw //true,显示特征点和中心三角;false 不显示
);
this->m_nTzhdNum=m_Minutia[0];
UpdateData(false);
}
void CArithProcession::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
if(sbmp1)
sbmp1->DrawDib(m_Image1.GetDC(),1,0,0);
}
BOOL CArithProcession::OnEraseBkgnd(CDC* pDC)
{
// theApp.backbmp.ReadFile(theApp.m_backfilename);//"c:\\z1.bmp"
CRect rect;
GetClientRect(&rect);
for (int nX = 0; nX < rect.Width(); nX +=theApp.backbmp. m_Width)
for (int nY = 0; nY < rect.Height(); nY +=theApp.backbmp. m_Height)
theApp.backbmp.DrawDib(pDC,1,nX,nY);
return TRUE;
}
HBRUSH CArithProcession::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_EDIT||nCtlColor==CTLCOLOR_LISTBOX)
return hbr;
else
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(theApp.m_textcolor);
return ((HBRUSH)::GetStockObject(HOLLOW_BRUSH));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -