Beispiel #1
0
        public void Dispose()
        {
            this.fingerDetectionTimer.Change(Timeout.Infinite, Timeout.Infinite);
            this.fingerDetectionTimer.Dispose();

            LibScanApi.ftrScanCloseDevice(this.handle);
        }
Beispiel #2
0
        private void FingerDetectionCallback(object state)
        {
            var result = LibScanApi.ftrScanIsFingerPresent(this.handle, out pFrameParameters);

            if (!result)
            {
                // There could be an error
                // var error = LibScanApi.GetLastError();
                return;
            }

            var lastFingerDetectedResult = pFrameParameters.nContrastOnDose2 > FingerDetectionContrastThreshold;

            if (lastFingerDetectedResult && !this.IsFingerPresent)
            {
                this.IsFingerPresent = true;
                this.OnFingerDetected();
            }

            if (!lastFingerDetectedResult && this.IsFingerPresent)
            {
                this.IsFingerPresent = false;
                this.OnFingerReleased();
            }
        }
Beispiel #3
0
        public Bitmap ReadFingerprint()
        {
            var t = new LibScanApi._FTRSCAN_IMAGE_SIZE();

            LibScanApi.ftrScanGetImageSize(this.handle, out t);

            byte[] arr = new byte[t.nImageSize];
            LibScanApi.ftrScanGetImage(this.handle, NDose, arr);

            var width  = t.nWidth;
            var height = t.nHeight;

            var image = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    byte a = (byte)(0xFF - arr[(y * width) + x]);

                    image.SetPixel(x, y, Color.FromArgb(a, a, a));
                }
            }

            return(image);
        }
Beispiel #4
0
        public LedState GetLedState()
        {
            LibScanApi.ftrScanGetDiodesStatus(this.handle, out greenIsOn, out redIsOn);

            return(new LedState()
            {
                GreenIsOn = greenIsOn,
                RedIsOn = redIsOn,
            });
        }
        public FingerprintDevice AccessFingerprintDevice()
        {
            var handle = LibScanApi.ftrScanOpenDevice();

            if (handle != IntPtr.Zero)
            {
                return(new FingerprintDevice(handle));
            }

            throw new Exception("Cannot open device");
        }
Beispiel #6
0
        protected void SetRedLed(bool state)
        {
            lock (this.ledStatusWritingLock)
            {
                LibScanApi.ftrScanGetDiodesStatus(this.handle, out greenIsOn, out redIsOn);

                redIsOn = state;

                LibScanApi.ftrScanSetDiodesStatus(this.handle, (byte)(greenIsOn ? 255 : 0), (byte)(redIsOn ? 255 : 0));
            }
        }
Beispiel #7
0
 public void SwitchLedState(bool green, bool red)
 {
     LibScanApi.ftrScanSetDiodesStatus(this.handle, (byte)(green ? 255 : 0), (byte)(red ? 255 : 0));
 }