/// <summary>
        /// 获取指纹
        /// </summary>
        /// <param name="buffer">指纹在设备中临时存放位置 1 2</param>
        /// <returns></returns>
        int GetFinger(int buffer)
        {
            TimeOut = 20;
            int ret = 0;

            byte[] ImgData = new byte[ImageSize];
            int[]  ImgLen  = new int[1];
            int    iBuffer = buffer;

BEIG1:
            ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);              //获取图象
            if (ret == 0)
            {
                ShowInfomation("获取图像成功...");
            }
            else if (ret == 2)
            {
                //超时判断
                ShowInfomation("等待手指平放在传感器上-" + TimeOut.ToString() + "秒");
                if (TimeOut < 0)
                {
                    ShowInfomation("等待超时");
                    return(0);
                }
                TimeOut--;
                Thread.Sleep(1000);
                goto BEIG1;
            }
            else
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            //////////////////////////////////////////////////////////////////////////
            //不涉及图像,下面可以省略
            /****************上传图像*********/

            ShowInfomation("正在上传图像请等待...");
            ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);              //上传图象
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            //strFile = System.Windows.Forms.Application.StartupPath + "\\ZAZFinger.bmp";
            strFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZAZFinger.bmp");
            ret     = Fingerdll.ZAZImgData2BMP(ImgData, strFile);
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            ShowImage(strFile);
            //ret = Fingerdll.ZAZShowFingerData(fpbmp.Handle, ref ImgData[0]);
            //////////////////////////////////////////////////////////////////////////
            /****************生成特征 *********/
            ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);              //生成模板
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            else
            {
                ShowInfomation("生成指纹特征" + buffer.ToString());
            }
            Thread.Sleep(10);
BEIG2:
            if (ret == 0)
            {
                ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);                  //获取图象
                ShowInfomation("等待手指拿开-");
                goto BEIG2;
            }
            else if (ret == 1)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            return(1);
        }
Beispiel #2
0
        /// <summary>
        /// 获取指纹
        /// </summary>
        /// <param name="buffer">指纹在设备中临时存放位置 1 2</param>
        /// <returns></returns>
        int GetFinger(int buffer)
        {
            TimeOut = 20;
            int ret = 0;

            byte[] ImgData = new byte[ImageSize];
            int[]  ImgLen  = new int[1];
            int    iBuffer = 1;

BEIG1:
            ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);              //获取图象
            if (ret == 0)
            {
                ShowToolTip("获取图像成功...");
            }
            else if (ret == 2)
            {
                //超时判断
                ShowToolTip("等待手指平放在传感器上-" + TimeOut.ToString() + "秒");
                if (TimeOut < 0)
                {
                    ShowToolTip("等待超时");
                    return(0);
                }
                TimeOut--;
                Thread.Sleep(1000);
                goto BEIG1;
            }
            else
            {
                //ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            //////////////////////////////////////////////////////////////////////////
            //不涉及图像,下面可以省略
            /****************上传图像*********/

            ShowToolTip("正在上传图像请等待...");
            ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);              //上传图象
            if (ret != 0)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }

            ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);              //生成模板
            if (ret != 0)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            else
            {
                ShowToolTip("生成指纹特征" + buffer.ToString());
                return(1);
            }
BEIG2:
            if (ret == 0)
            {
                ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);                  //获取图象
                ShowToolTip("等待手指拿开-");

                goto BEIG2;
            }
            else if (ret == 1)
            {
                ShowToolTip(Fingerdll.ZAZErr2Strt(ret));
                return(0);
            }
            return(1);
        }