I'm using Digital Persona Finger Print device and need to capture the image as WSQ
format instead of Bmp
format
Using C#
DigitalPersona One Touch for Windows SDK
Sample Code
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);
}
I found library in C# that convert bmp
to wsq
wsqEncodeDecode but the result of wsq
are not correct,
Any solution that return the captured image in wsq
format directly from the sdk?
To Achieve exactly what i need i do the following:
I used 2 libraries
1 - AForge.Imaging , AForge.Imaging.Formats and Delta.Wsq DLL's
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);
}
And is method to do resize
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;
}