private void _fingerImageTimer_Tick(object sender, EventArgs e) { _fingerImageTimer.Stop(); _cbCapTmp = 2048; if (_flagFinger == "1") { this.nRet = ZwClass.ZKFPModule_GetFingerImage(this.m_hDevice, ref this.m_nWidth, ref this.m_nHeight, this.m_pImageBuffer, ref this.m_nSize); if (this.nRet == 0) { try { MemoryStream ms = new MemoryStream(); BitmapFormat.WriteBitmap(this.m_pImageBuffer, this.m_nWidth, this.m_nHeight); BitmapFormat.GetBitmap(this.m_pImageBuffer, this.m_nWidth, this.m_nHeight, ref ms); Bitmap bitmap = new Bitmap((Stream)ms); this.PictureBox_Finger.SizeMode = PictureBoxSizeMode.StretchImage; this.PictureBox_Finger.Image = (System.Drawing.Image)bitmap; SaveFingerOrSignImage(ms); } catch (Exception ex) { LoggerHelper.Log(ex.Message); } } else { LoggerHelper.Log("this.nRet:" + this.nRet); } } else { this.nRet = FingerClass.AcquireFingerprint(this.m_hDevice, this._fPBuffer, this._capTmp, ref this._cbCapTmp); if (this.nRet == 0) { MemoryStream ms = new MemoryStream(); FingerBitmapFormat.GetBitmap(this._fPBuffer, this.m_nWidth, this.m_nHeight, ref ms); Bitmap bitmap = new Bitmap((Stream)ms); this.PictureBox_Finger.SizeMode = PictureBoxSizeMode.StretchImage; this.PictureBox_Finger.Image = (System.Drawing.Image)bitmap; SaveFingerOrSignImage(ms); ms.Dispose(); } } _fingerImageTimer.Start(); }
private void Button_InputFinger_Click(object sender, RoutedEventArgs e) { if (_flagFinger == "1") { if (this.m_hDevice == IntPtr.Zero || (uint)this.nRet > 0U) { if (IntPtr.Zero != this.m_hDevice) { ZwClass.ZKFPModule_Disconnect(this.m_hDevice); } this.m_hDevice = ZwClass.ZKFPModule_Connect("protocol=USB,vendor-id=6997,product-id=289"); } } else { if (this.m_hDevice == IntPtr.Zero || (uint)this.nRet > 0U) { if (IntPtr.Zero != this.m_hDevice) { FingerClass.CloseDevice(this.m_hDevice); } FingerClass.Init(); this.m_hDevice = FingerClass.OpenDevice(0); byte[] numArray = new byte[4]; int size = 4; FingerClass.GetParameters(this.m_hDevice, 1, numArray, ref size); FingerClass.ByteArray2Int(numArray, ref this.m_nWidth); FingerClass.GetParameters(this.m_hDevice, 2, numArray, ref size); FingerClass.ByteArray2Int(numArray, ref this.m_nHeight); this._fPBuffer = new byte[this.m_nWidth * this.m_nHeight]; } } this.PictureBox_Finger.Refresh(); if (this.PictureBox_Finger.Image != null) { this.PictureBox_Finger.Image.Dispose(); this.PictureBox_Finger.Image = null; } _fingerImageTimer.Stop(); _fingerImageTimer.Tick -= _fingerImageTimer_Tick; _fingerImageTimer.Tick += _fingerImageTimer_Tick; _fingerImageTimer.Interval = TimeSpan.FromSeconds(1); _fingerImageTimer.Start(); }