作为 WSQ 的 Digital Persona Finger Print 捕获图像

Digital Persona Finger Print captured image as WSQ

我正在使用 Digital Persona 指纹设备,需要将图像捕获为 WSQ 格式而不是 Bmp 格式
使用 C# DigitalPersona One Touch for Windows SDK

示例代码

private DPFP.Capture.SampleConversion SampleConversion;
private Bitmap Image;
public async void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
        {

            var imgName = string.Format("fingerprint{0}.bmp", DateTime.Now.Ticks);
            SampleConversion.ConvertToPicture(Sample, ref Image);
            Image.Save(imgName, System.Drawing.Imaging.ImageFormat.Bmp);
        }

我在 C# 中找到了将 bmp 转换为 wsq wsqEncodeDecode 的库,但是 wsq 的结果不正确,
return 直接从 sdk 中以 wsq 格式捕获的图像?

为了实现我所需要的,我做了以下事情:

我使用了 2 个库

1 - AForge.Imaging , AForge.Imaging.Formats and Delta.Wsq DLL 的

            private Bitmap Image;

        public async void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
           {
            SampleConversion.ConvertToPicture(Sample, ref Image);
            Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            Image = resizeImage(364, 400, Image);
            var img8bppx = Grayscale.CommonAlgorithms.BT709.Apply(Image);

            var rawImageData = Conversions.GdiImageToImageInfo(img8bppx);
            WsqEncoder encoder = new WsqEncoder();
            var result = encoder.Encode(rawImageData);
            }

并且是调整大小的方法

public Bitmap resizeImage(int newWidth, int newHeight, Image imgPhoto)
        {
            int sourceWidth = imgPhoto.Width;
            int sourceHeight = imgPhoto.Height;

            //Consider vertical pics
            if (sourceWidth < sourceHeight)
            {
                int buff = newWidth;

                newWidth = newHeight;
                newHeight = buff;
            }

            int sourceX = 0, sourceY = 0, destX = 0, destY = 0;
            float nPercent = 0, nPercentW = 0, nPercentH = 0;

            nPercentW = ((float)newWidth / (float)sourceWidth);
            nPercentH = ((float)newHeight / (float)sourceHeight);
            if (nPercentH < nPercentW)
            {
                nPercent = nPercentH;
                destX = System.Convert.ToInt16((newWidth -
                          (sourceWidth * nPercent)) / 2);
            }
            else
            {
                nPercent = nPercentW;
                destY = System.Convert.ToInt16((newHeight -
                          (sourceHeight * nPercent)) / 2);
            }

            int destWidth = (int)(sourceWidth * nPercent);
            int destHeight = (int)(sourceHeight * nPercent);


            Bitmap bmPhoto = new Bitmap(newWidth, newHeight,
                          PixelFormat.Format24bppRgb);

            bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
                         imgPhoto.VerticalResolution);

            Graphics grPhoto = Graphics.FromImage(bmPhoto);
            grPhoto.Clear(Color.Black);
            grPhoto.InterpolationMode =
                System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            grPhoto.DrawImage(imgPhoto,
                new Rectangle(destX, destY, destWidth, destHeight),
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                GraphicsUnit.Pixel);

            grPhoto.Dispose();
            imgPhoto.Dispose();
            return bmPhoto;
        }