1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
void CTestFaceServerSdkDlg::OnEventCEnrollUserFaceserversdkctrl1( LPCTSTR strDevSn , //终端序列号 m_devSn long lOpCode , //操作标识 OP_SUCC=0 成功 OP_FAIL=1 失败 long lUserData , //用户传进来的自定义数据 long lExtendParam , //扩展参数 long lUserId , //用户编号 LPCTSTR strCardNo , //卡号 long lFeatureLen , //特征码原始长度 LPCTSTR strBase64FeatureData , //经过BASE64编码的特征数据 long lPhotoType , //照片类型保留 long lPhotoLen , //照片原始数据长度 LPCTSTR strBase64PhotoData //经过BASE64编码的照片数据 ) { // TODO: 在此处添加消息处理程序代码 if(lPhotoLen > 0) { MessageBox( _T( "人脸登记成功" ) ); int nBase64PhotoLen = wcslen( strBase64PhotoData ); if(nBase64PhotoLen > 1024) { char szBuffer[ BUF_LEN ] = { 0 }; char* pDst = szBuffer; CBase64 * cBase64 = new CBase64; int nDstLen = cBase64->DecodeBase64( (const char*)( CW2A( strBase64PhotoData ) ) , (unsigned char*)pDst , nBase64PhotoLen ); CString strSuffix; strSuffix.Format( _T( "%d" ) , lUserId ); CString strFileName; SYSTEMTIME sys; GetLocalTime( &sys ); strFileName.Format( _T( ".\\PHOTO_%s_%04d%02d%02d%02d%02d%02d%03d_%s.jpg" ) , _T( "GetUserInfo" ) , sys.wYear , sys.wMonth , sys.wDay , sys.wHour , sys.wMinute , sys.wSecond , sys.wMilliseconds , strSuffix ); CFile file; CFileException ex; if(file.Open( strFileName , CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate , &ex )) { file.Write( szBuffer , nDstLen ); file.Flush(); file.Close(); } } } } |
先暂存一下…
从图片获取数据显示在界面上:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
//文件读取方法: int cx , cy; CImage image; CRect rect; //根据路径载入图片 image.Load( strFileName ); //获取图片的宽 高度 cx = image.GetWidth(); cy = image.GetHeight(); //获取Picture Control控件的大小 GetDlgItem( IDC_STATIC_PIC )->GetWindowRect( &rect ); //将客户区选中到控件表示的矩形区域内 ScreenToClient( &rect ); //窗口移动到控件表示的区域 GetDlgItem( IDC_STATIC_PIC )->MoveWindow( rect.left , rect.top , cx , cy , TRUE ); CWnd *pWnd = NULL; pWnd = GetDlgItem( IDC_STATIC_PIC );//获取控件句柄 pWnd->GetClientRect( &rect );//获取句柄指向控件区域的大小 CDC *pDc = NULL; pDc = pWnd->GetDC();//获取picture的DC image.Draw( pDc->m_hDC , rect );//将图片绘制到picture表示的区域内 ReleaseDC( pDc ); |
Base64数据流直接显示到界面上:
[crayon-673ef0[……]