how can i get xml fid digitalpersona

0

I have an application in Xamarin forms that uses digital persona which I adapted successfully from this code of Android java

The problem is that this app returns only a byte[] array of a fingerprint, so i need to send fid xml to web service so i can compare validate fingers but i dont know how

heres is the class that i use to parse stream from digital persona to array byte

public class UruImage
{

    private static int IMAGE_HEIGHT = 290;
    private static int IMAGE_WIDTH = 384;
    private static int QUALITY = 75;
    private static string LOG_TAG = "U.are.U-Image ";

    // Raw data
    private short unknown_00;
    private byte[] unknown_07 = new byte[9];
    private byte[] unknown_2E = new byte[18];

    public short num_lines;
    public short width;
    public sbyte key_number;
    public byte[] flags_num_lines = new byte[30];
    public byte[] data;

    // setter & getter

    public void createFromData(ByteBuffer sData) //throws IOException
    {
        try
        {
            //tengo duda con lo indices en codigo java esta sData.GetShort(); sin index
            sData.Order(ByteOrder.LittleEndian);

            unknown_00 = sData.Short;
            System.Console.WriteLine(LOG_TAG+" unknown_00: " + Convert.ToString(unknown_00));

            width = sData.Short;
            System.Console.WriteLine(LOG_TAG+ "width: " + Convert.ToString(width));

            num_lines = sData.Short;
            System.Console.WriteLine(LOG_TAG+ "num_lines: " + Convert.ToString(num_lines));

            key_number = sData.Get();
            System.Console.WriteLine(LOG_TAG+ "key_number: " + Convert.ToString(key_number));

            sData.Get(unknown_07, 0, 9);
            System.Console.WriteLine(LOG_TAG+ "unknown_07: " + bytesToHex(unknown_07));

            sData.Get(flags_num_lines, 0, 30);
            System.Console.WriteLine(LOG_TAG, "flags_num_lines: " + bytesToHex(flags_num_lines));

            sData.Get(unknown_2E, 0, 18);
            System.Console.WriteLine(LOG_TAG+ "unknown_2E: " + bytesToHex(unknown_2E));

            data = new byte[(num_lines + 1) * width]; // extra line for decoding
            sData.Get(data, 0, num_lines * width);
        }
        catch (Exception ex) {
            System.Console.WriteLine(" createFromData " + ex.Message + " " + ex.ToString());
            throw new  Java.IO.IOException();
        }


    }

    public Byte[] getImageBitmap()
    {
        try
        {
            int dataOffset = 0;

            int[] pixels = new int[IMAGE_WIDTH * IMAGE_HEIGHT];
            int i = 0;
            for (int y = 0; y < IMAGE_HEIGHT; y++)
            {
                for (int x = 0; x < IMAGE_WIDTH; x++)
                {
                    int gray = data[dataOffset + i] & 0xff;
                    pixels[i] = unchecked((int)0xff000000) | gray << 16 | (gray << 8) | gray;
                    i++;
                }
            }

            Bitmap bm = Bitmap.CreateBitmap(pixels, IMAGE_WIDTH, IMAGE_HEIGHT, Bitmap.Config.Argb8888);
            MemoryStream bs = new MemoryStream();
            bm.Compress(Bitmap.CompressFormat.Jpeg, QUALITY, bs);
            return bs.ToArray();
        }
        catch (System.Exception ex) {
            System.Console.WriteLine("Get Image bitmap" + ex.Message + " " + ex.StackTrace);
        }
        return new MemoryStream().ToArray();
    }

    public byte[] getPgm()
    {
        return data;
    }

    public void invert()
    {
        try
        {
            int length = width * num_lines;
            int i;
            //duda con conversion de valor byte max_value = 0xFFFFFFFF;
            byte max_value = unchecked((byte)0xFFFFFFFF);
            for (i = 0; i < length; i++)
            {
                data[i] = (byte)(max_value - data[i]);
            }
        }
        catch (System.Exception ex) {
            System.Console.WriteLine("Invert "+ex.Message);
        }
    }


    protected static char[] hexArray = "0123456789ABCDEF".ToCharArray();
    private static String bytesToHex(byte[] bytes)
    {
        char[] hexChars = new char[bytes.Length * 2];
        for (int j = 0; j < bytes.Length; j++)
        {
            int v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[(uint)v >> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }

}
c#
xamarin
asked on Stack Overflow Jul 11, 2019 by BagoeldeRojo

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0