读取二代身份证上面的相片,这个函数GetBmp(char * Wlt_File,int intf) 怎么用?
三、函数列表
GetBmp(char * Wlt_File,int intf) wlt文件解码成bmp文件;
四、函数说明
原 型:int GetBmp(char * Wlt_File,int intf);
说 明:本函数用于将wlt文件解码成bmp文件。
参 数:Wlt_File ----- wlt文件名
intf ----- 阅读设备通讯接口类型(1—RS-232C,2—USB)
返 回 值:生成*.bmp文件和以下返回信息
值 意义
1 相片解码解码正确
0 调用sdtapi.dll错误
-1 相片解码错误
-2 wlt文件后缀错误
-3 wlt文件打开错误
-4 wlt文件格式错误
-5 软件未授权
-6 设备连接错误
五、注意事项
1、 wlt文件的后缀要固定为”.wlt”,如:xp.wlt,相片解码成xp.bmp;
2、 本函数要与sdtapi.dll关联使用,并确认通讯端口处于关闭状态;
这是读取相片的文档,我现在把身份证上面的信息读取出来了 , 就是图片这里出了问题,图片是乱码,不知道GetBmp()第一个参数是什么值?
这是代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SDT_StartFindIDCard(int iPort, byte[] pucManaInfo, int iIfOpen);
[DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SDT_OpenPort(int iPort);
[DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SDT_ClosePort(int iPort);
[DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SDT_SelectIDCard(int iPort, byte[] pucManaMsg, int iIfOpen);
[DllImport("WltRS.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetBmp(string pucPHMsg, int intf);
[DllImport("sdtapi.dll", CallingConvention = CallingConvention.StdCall)]
static extern int SDT_ReadBaseMsg(int iPort, byte[] pucCHMsg, ref UInt32 puiCHMsgLen, byte[] pucPHMsg, ref UInt32 puiPHMsgLen, int iIfOpen);
private void button1_Click(object sender, EventArgs e)
{
byte[] CardPUCIIN = new byte[255];
byte[] pucManaMsg = new byte[255];
byte[] pucCHMsg = new byte[255];
byte[] pucPHMsg = new byte[3024];
UInt32 puiCHMsgLen = 0;
UInt32 puiPHMsgLen = 0;
int st = 0;
int iRet;
int iPort = 1001;
int iIfOpen = 0;
if (iIfOpen == 0)
{
iRet = SDT_OpenPort(iPort);
}
//读卡操作
st = SDT_StartFindIDCard(iPort, CardPUCIIN, iIfOpen);
if (st == 0x9f)//128
{
st = SDT_SelectIDCard(iPort, pucManaMsg, iIfOpen);
if (st != 0x90) return;//129
st = SDT_ReadBaseMsg(iPort, pucCHMsg, ref puiCHMsgLen, pucPHMsg, ref puiPHMsgLen, iIfOpen);
if (st != 0x90) return;
}
else
{
if (iIfOpen == 0)
{
//关闭
SDT_ClosePort(iPort);
return;
}
}
if (iIfOpen == 0)
{
//关闭
SDT_ClosePort(iPort);
}
就这个函数不知道怎么用
//int img = GetBmp(Application.StartupPath + @"\xp.wlt", 2);
//int img = GetBmp(pucPHMsg,2);
Card card = new Card(pucCHMsg,pucPHMsg);
//显示结果
this.txtname.Text = card.Name;
string nations = card.Nation;
if (nations == "01")
nations = "汉族";
else
nations = "其他民族";
this.txtnation.Text = nations;
string sexs = card.Sex;
if (sexs == "1")
sexs = "男";
else if (sexs == "2")
sexs = "女";
else
sexs = "其他";
this.txtsex.Text = sexs;
this.txtdate.Text = card.Date;
this.txtaddres.Text = card.Address;
this.txtcardId.Text = card.CardId;
this.txtorgan.Text = card.Organ;
this.txtbegin.Text = card.Begin + "-" + card.End;
}
}
class Card
{
#region 字段
//身份证号码
private string cardId;
public string CardId
{
get { return cardId; }
set { cardId = value; }
}
//姓名
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
//性别
private string sex;
public string Sex
{
get { return sex; }
set { sex = value; }
}
//民族
private string nation;
public string Nation
{
get { return nation; }
set { nation = value; }
}
//出生日期
private string date;
public string Date
{
get { return date; }
set { date = value; }
}
//地址
private string address;
public string Address
{
get { return address; }
set { address = value; }
}
//发证机关
private string organ;
public string Organ
{
get { return organ; }
set { organ = value; }
}
//起始日期
private string begin;
public string Begin
{
get { return begin; }
set { begin = value; }
}
//截止日期
private string end;
public string End
{
get { return end; }
set { end = value; }
}
//图片
private Image picture;
public Image Picture
{
get { return picture; }
set { picture = value; }
}
#endregion
public Card(byte[] pucCHMsg, byte[] pucPHMsg)
{
这里返回所有的信息就相片是乱码,是一个正方形
string messge = System.Text.ASCIIEncoding.Unicode.GetString(pucCHMsg);
this.name = messge.Substring(0, 15);
messge = messge.Substring(15);
this.sex = messge.Substring(0, 1);
messge = messge.Substring(1);
this.nation = messge.Substring(0, 2);
messge = messge.Substring(2);
this.date = messge.Substring(0, 8);
messge = messge.Substring(8);
this.address = messge.Substring(0, 35);
messge = messge.Substring(35);
this.cardId = messge.Substring(0, 18);
messge = messge.Substring(18);
this.organ = messge.Substring(0, 15);
messge = messge.Substring(15);
this.begin = messge.Substring(0, 8);
messge = messge.Substring(8);
this.end = messge.Substring(0, 8);
messge = messge.Substring(8);
}
}
}
我该怎么得到这张相片