身份证识别仪读取的照片数据如何转成图片?
这里是代码,在坛子里找的!我在prg里调试后,可以显示字符数据,不能生成照片文件。
程序代码:
clear dlls clear DECLARE Integer SDT_OpenPort IN sdtapi.dll Integer iPort DECLARE Integer SDT_ClosePort IN sdtapi.dll Integer iPort DECLARE Integer SDT_StartFindIDCard IN sdtapi.dll Integer iPort, String @pucManaInfo, Integer iIfOpen DECLARE Integer SDT_SelectIDCard IN sdtapi.dll Integer iPort, String @pucManaMsg, Integer iIfOpen DECLARE Integer SDT_ReadBaseMsg IN sdtapi.dll Integer iPort, String @pucCHMsg, Integer @puiCHMsgLen, String @pucPHMsg, Integer @puiPHMsgLen, Integer iIfOpen LOCAL iRet As Integer && 返回码 LOCAL iPort As Integer && 端口号 LOCAL iIfOpen As Integer && 是否需要打开端口 LOCAL pucManaInfo As String LOCAL pucManaMsg As String LOCAL pucCHMsg As String && 文字信息 LOCAL pucPHMsg As String && 照片信息 LOCAL pucFPMsg As String && 指纹信息 LOCAL uiCHMsgLen As Integer, uiPHMsgLen As Integer iRet = 0 pucManaInfo = SPACE(4) pucManaMsg = SPACE(8) pucCHMsg = SPACE(512) pucPHMsg = SPACE(1024) pucFPMsg = SPACE(1024) uiCHMsgLen = 0 uiPHMsgLen = 0 iPort = 1001 && 端口在系统设置下设置 1001为USB 设备 iIfOpen = 0 IF iIfOpen = 0 iRet = SDT_OpenPort(iPort) IF iRet != 0x90 MESSAGEBOX("SDT_OpenPort 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误') SDT_ClosePort(iPort) RETURN ENDIF ENDIF DO WHILE .T. && 找卡 iRet = SDT_StartFindIDCard(iPort, @pucManaInfo, iIfOpen) IF iRet = 0x9f iRet = SDT_SelectIDCard(iPort, @pucManaMsg, iIfOpen) IF iRet == 0x90 EXIT ENDIF ENDIF IF MESSAGEBOX("没有找到身份证,请放身份证?", 32 + 4, '询问') <> 6 EXIT ENDIF ENDDO iRet = SDT_ReadBaseMsg(iPort, @pucCHMsg, @uiCHMsgLen, @pucPHMsg, @uiPHMsgLen, iIfOpen) IF iRet != 0x90 MESSAGEBOX("SDT_ReadBaseMsg 错误, 错误代码为 " + LTRIM(STR(iRet)), 16, '错误') IF iIfOpen = 0 SDT_ClosePort(iPort) RETURN ENDIF ENDIF tmp_read=STRCONV(left(pucCHMsg,uiCHMsgLen),6) xm_read=ALLTRIM(LEFTC(tmp_read,15)) &&读出的字符串前15位是姓名 xbpd=SUBSTRC(tmp_read,16,1) &&读出的字符串前16位是性别,1代表男,2代表女 mzpd=SUBSTRC(tmp_read,17,2) &&读出的字符串前17-18位是民族,01是汉族 tmp_rq=SUBSTRC(tmp_read,19,8) &&读出的字符串前19-25位是出生日期 IF xbpd="1" xb_read="男" ELSE xb_read="女" ENDIF ***********这里翻译民族的有没有更好方法? DO CASE CASE mzpd="01" mz_read="汉" ENDCASE csrq_read=LEFT(tmp_rq,4)+'.'+SUBSTR(tmp_rq,5,2)+'.'+SUBSTR(tmp_rq,7,2) dz_read=SUBSTRC(tmp_read,27,35) &&地址的数据 sfzhm_read=SUBSTRC(tmp_read,62,18) &&身份证号码的数据 qfjg_read=ALLTRIM(SUBSTRC(tmp_read,80,15)) &&签发机关的数据 tmp_rqq=SUBSTRC(tmp_read,95,8) &&签发日期 tmp_rqz=SUBSTRC(tmp_read,103,8) &&有限期限 yxqq_read=LEFT(tmp_rqq,4)+'.'+SUBSTR(tmp_rqq,5,2)+'.'+SUBSTR(tmp_rqq,7,2) yxqz_read=LEFT(tmp_rqz,4)+'.'+SUBSTR(tmp_rqz,5,2)+'.'+SUBSTR(tmp_rqz,7,2) qtxx_read=RIGHTC(tmp_read,18) &&其他内容,暂时不知道是什么 *photo_tmp=SYS(5)+SYS(2003)+"\"+ALLTRIM(xm_read)+alltrim(sfzhm_read)+".bmp" &&这里是获得照片的程序 photo_tmp=SYS(5)+SYS(2003)+"\"+ALLTRIM(xm_read)+alltrim(sfzhm_read)+".wlt" &&这里是获得照片的程序 =STRTOFILE(LEFT(pucPHMsg,uiPHMsgLen),photo_tmp) *kk=Strconv(LEFT(pucPHMsg,uiPHMsgLen),6) *dd=Strconv(LEFT(pucPHMsg,uiPHMsgLen),5) *STRTOFILE(dd,photo_tmp) **************可以生成wlt文件,如何转成图片。 ? xm_read ? xb_read ? mz_read ? csrq_read ? dz_read ? sfzhm_read ? qfjg_read ? yxqq_read ? yxqz_read ? qtxx_read IF iIfOpen = 0 &&关闭端口 SDT_ClosePort(iPort) clear dlls RETURN ENDIF clear dlls
生成的wlt文件:
xp.rar
(1.39 KB)