private void DrawCapturedImage(UFScanner Scanner) { Graphics g = pbImageFrame.CreateGraphics(); Rectangle rect = new Rectangle(0, 0, pbImageFrame.Width, pbImageFrame.Height); try { // //Scanner.DrawCaptureImageBuffer(g, rect, cbDetectCore.Checked); // Bitmap bitmap; int Resolution; Scanner.GetCaptureImageBuffer(out bitmap, out Resolution); pbImageFrame.Image = bitmap; } finally { g.Dispose(); } }
private UFS_STATUS ExtractTemplate(UFScanner scanner) { try { byte[] template = new byte[TemplateBufferSize]; int enrollQuality = 0; UFS_STATUS ufsRes = scanner.Extract(template, out _templateSize, out enrollQuality); if (ufsRes == UFS_STATUS.OK) { if (template.Length != TemplateBufferSize) { //WriteLog(true, "Invalid template size, try again"); //return UFS_STATUS.ERR_NOT_GOOD_IMAGE; byte[] tmp = new byte[TemplateBufferSize]; for (int i = template.Length - 1; i < tmp.Length; i++) { tmp[i] = 0; } template = tmp; } WriteLog("Template capturing completed"); WriteLog(string.Format("Template quality is {0}", enrollQuality)); if (enrollQuality < Settings.MinimalTemplateQualityPercent) { MessageBoxResult result = MessageBox.Show("The quality of captured template is too low for using it, Would you like to retry template capturing?", "Poor template quality", MessageBoxButton.YesNo, MessageBoxImage.Information); if (result == MessageBoxResult.Yes) { CaptureTemplate(this, null); } } else { _template = Encoding.ASCII.GetString(TemplateConverter.ConvertToSynelTemplateFormat(template)); System.Drawing.Bitmap bitm = null; int resolution = 0; scanner.GetCaptureImageBuffer(out bitm, out resolution); fingerImage.Source = loadBitmap(bitm); } } else { string error = string.Empty; UFScanner.GetErrorString(ufsRes, out error); WriteLog(error, false); } return(ufsRes); } catch (Exception exc) { WriteLog(exc.Message, true); } return(UFS_STATUS.ERROR); }